Zalo DS Blog

Friday, July 17, 2015

3DS Homebrew Tips and Tricks (I)

So, as I said on my previous post I am gonna start a series of posts talking about some things that might be useful for those of you intereseted on developing for this machine. For me this is just a hobby and I cannot dedicate 100% of my time, just 1 hour a day and a little bit more during the weekends, so being stuck on something is a bit frustrating.

I have spent much more time stuck on some stuff and searching on forums than actually coding. Hoping that this will help you I have made a compilation of the things that would had saved me a lot of time if I had knew how they were before.

This is the 1st post on the series 3DS Homebrew Tips and Tricks

1. 3dsx, Cia and 3ds

These are the 3 formats that you can compile your programs into.

- 3dsx this is the format that the ctrulib (which is the SDK for homebrew in 3DS) supports officially. If you are gonna release something you should distribute it under this format. You need to execute the Homebrew Launcher to use it. You need to execute ninjhax for that. The problem is, some of us cannot do this, either because we don't have Cubic Ninja or because we have updated our emunands beyond 9.2 and now it doens't work anymore (take a look at this post)

- Cia this is the format that you use for stuff that needs to be installed in the console (as channels). Some people doesn't like it because it has been used a lot for piracy (way more than for homebrew). You need to use a CFW (Custom Firmware) and then a CFW installer in order to use it. You don't need a flaschcard for this but your console needs to be on 4.5 firmware

- 3ds this file is the oficial format supported by nintendo. You need a flashcard for this and that's why some people doesn't like it.

As I said the makefiles that come with the ctrulib only support building for 3dsx. If you want to create your own makefiles supporting those formats you can take a look at the ones used in GameYob. You still need to take a look at how to create banners, icons and sounds but I will cover that on the 3rd point.

2. Setting up a good Developement environment

I am not going to cover here how to get started with 3ds homebrew. You can take a look at my previous post here. In sort you need to download devkitpro and from there devkitARM. I don't recommend installing ctrulib from devkitpro. The version that comes with it doesn't include examples and it is hardly up to date. Your best option is getting ctrulib from github and compiling it yourself. You need to be careful because then you are gonna be working with a library that is not stable but you can always take a look at the changes and see what's going on. I usually update it once a month unless there is an important update.

Take some time compiling and running the examples. If one of them doesn't work take a look at the last time it was updated and try again with a branch created on that day. If you are planing to do 3d games the best start point for you is the gpu example.
Once you reach the point when you have compiled and executed some examples and played with them a bit using programmers notepad (or any other text editor you want) you might start considering using another IDE a bit more powerful

The one that I am using is Visual Studio 2010 but what I am gonna post here should be very similar in any other version.
 - Create a makefile project

 - Linking it to our Makefile
 Go to Project properties and configure it like this:
    - Build command line: 
    - Clean commands: 
                            make clean
    - Rebuild command line: 
                            make clean 

you can now close visual studio go where you have created this project and copy it into the folder of the example you want to compile. After that if you open it and compile, it will run the makefile and create a 3dsx as expected. Rebuild and clean will also be working as usual

- Adding intellisense
Add the next paths into the Include Search Path
 - C:\devkitPro\devkitARM\arm-none-eabi\include
 - C:\devkitPro\devkitARM\include
 - C:\devkitPro\libctru_git\libctru\include
where C:\devkitPro is the folder in your harddrive where you have installed devkitpro
Now code completion should be working as well as going to function declaratinos.

 - Creating a external tool for copying contents into the console
   - In yout makefile add a target called install similar to this:
                  cp ../bin/$(PROJECT_NAME).3ds g:/
                     @echo Done 

   - Go to Tools/External Tools
   - Add a new Tool called Install like this
   - Now Create a New Toolbar called Homebrew (Tools/Customize/New...)
   - Go the Commands tab and select the toolbar created. Press Add Command and in Tools search select External Command 7 (yeah.. this is a bit ughhh... but it works)
You should now see your new ToolBar located in the Toolbars and a the button Install on it
Now when you compile you just need to put the SD on your computer, press Install, wait for the message "Done" and put it back on your console to execute

This is very useful if you have a flashcard and you work with the 3ds format. Actually this is the fastest way to work. Compilation times are big and you need to reduce it the maximum posible (bear in mind that sometimes you just change the value of one var and recompile and you need to see the results as soon as posible). This is how I usually work
- I run the latest build on my 3ds and see that something doesn't work
- I take a look at the code, detect what's happening and make some changes. Then press F7 to compile
- While compiling I stop the build on the 3ds (by pressing the home menu and then closing the app)
- I take out the flashcard form the console, then the micro SD inside it and put it on my laptop
- By that time the compilation has finished so I jsut press Install
- I wait for the "Done" message, take out the micro SD from my laptop, and plug it in on the flashcard
- I put the flashcard on the console, select the rom and run it

This is usually about 20 seconds, which is not bad. And it is actually faster than sending the build via FTP (because you need to launch the client on the console for that, then send it form your computer, then close it... and it fails a lot). 

It is even worst if you work with cias, because you need to install them on the internal SD and you cannot remove the SD while on emunad (the console freezes). You can again send the content via wifi (using the tool from nintendo is the best way, see this post) but it takes too much time.

Again, this is up to you, but for applications that are big I highly recommend getting a flashcard and working with 3ds files directly.


  • I wonder if some downloader using a network protocol where data is always ready to be transmitted would be FTP here. It was clearly a winner on the NDS, but the 3DS is much slower in its boot steps.
    Do smealum's library already provide a mechanism to launch one .3ds file from another ?

    By Blogger Sylvain Pypebros, at July 24, 2015 9:54 PM  

  • I have recently been capable of running ninjhax 2.0 and yeah you can do that with ftbrony. The only problem for me is that in order to get there I need to go throught 2 exploits (one for the flashcard, and then one for cubic ninja). When it crashes (and it does) I lose a lot of time putting things up again

    By Blogger Zalo, at July 26, 2015 6:08 PM  

Post a Comment

<< Home