DS Programming Environment On Windows

Discussion in 'NDS - Tutorials' started by Rydian, May 12, 2011.

May 12, 2011
  1. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    -

    Look at this guide instead, it's better.
    The previous guide is still contained below, for historical reasons or some crap like that.​



    DS Programming Environment On Windows


    Looking to program for the Nintendo DS, DSi, and 3DS (in DS or DSi-mode)?
    Only dealt with interpreted languages before, need to learn how to compile?
    Not sure what tools are needed, where to get them, or how to set them up?

    This guide walks you through setting up and using the proper environment.​


    Installing devkitARM
    1. Downloading devkitARM

      Visit the sourceforge download page, and download devkitProUpdater-x.x.x.exe (whichever version is the latest).
      Warning: Spoilers inside!
    2. Running The Installer

      Run the installer you downloaded, choose Next, then choose Download and install/install from downloaded files, then click Next and choose to Remove downloaded files.
      Warning: Spoilers inside!
    3. Choosing The Components

      On this page you'll select the components of devkitPro to install. The minimal system is pretty much mandatory, then comes the three devkitPro aspects. For DS development we need devkitARM (ARM being the processor type the DS uses). devkitPPC is for PPC-based targets, and devkitPSP is for the PSP, so we're not concerned with those. The next choice is Programmer's Notepad. If you already have a code editor you prefer to use (such as Notepad++) then skip it, but this tutorial assumes we'll be installing it. After that is Insight, which is a debugger you may find very helpful later on, so it's recommended you install it as well.
      Warning: Spoilers inside!
    4. Install And Wait

      Choose whatever you'd like for the next two steps, then confirm. The installer needs to download, extract, set up, and install the selected components, which can take a while. When it's done click Next, and finish. Feel free to delete the installer when you're done. You'll also find a devkitProUpdate.txt file on your desktop, you can delete this.
      Warning: Spoilers inside!



    Basic Program Creation/Compiling
    1. Programmer's Notepad Associations

      You can't code stuff if you can't edit the code, right? Go to C:devkitProProgrammers Notepad (or wherever devkitpro is installed) and open up pn.exe (the Programmer's Notepad executable). Go to Tools - Options, then in the options window go down and click File Associations in the left. In the File Associations window, type cpp into the box in the upper-left, then click the add button. Do it again, but type just h instead of cpp, and then do it one more time for c. Close Programmer's Notepad.

      After this the source code for these projects should open with the programmer's notepad. Go to C:devkitProexamplesndshello_worldsource and double-click main.cpp, it should open in Programmer's Notepad now.
      Warning: Spoilers inside!
    2. Compiling

      Compiling is done through the windows commandline, but navigating to the right folder in Windows can be a bit of a pain, so we'll use a batch file to call the command in the right directory. Download this file and place a copy of it within your project's folder. Simply run it whenever you want to compile, and the tools that devkitPro set up will do the work for you. When the compiling is done (and assuming the project didn't have any coding errors) you should have your .nds file in the project folder!
      Warning: Spoilers inside!
    3. Testing

      Most homebrew will run in an emulator, and it's a lot easier than transferring to your flash cart to test every time, so it's suggested you download a DS emulator to test your creations with. While NO$GBA is very popular, it hasn't been updated in over three years. My recommendations are iDeaS and DeSmuME. Both of these emulators are more up-to-date, and both of them include the ability to drag-and-drop an .nds file into the emulator's window to launch it.
      Warning: Spoilers inside!



    (Optional) Additional Libraries



    //Basic C/++ functions
    #include

    //libnds functions
    #include

    //Nightfox's lib.
    #include

    While PAlib used to be the big recommended one, it's development has stopped and it's fallen out of favor.

    Nightfox's lib is a new one focusing on the graphical department and sprite manipulation (so users can make their own games quicker without having to worry as much about the technical back-end), so it's the recommended one for now. Visit Nightfox And Co. for the latest version, the download link near the bottom will lead you to sourceforge as before. In the download is a /docs/ folder, containing PDFs in both English and Spanish, with the function documentation.

    • While the default libnds library does contain a wide range of functions, these are not always the easiest to use for game development. To this end there have been multiple additional libraries aimed towards making homebrew development easier and quick, through the creation of many custom functions that do a lot of the hard work for you. These libraries are generally made up of various definition files, which define constants and custom functions inside themselves. In general adding a library is as simple as copying the definition files to a usable directory for the project, and then adding an include function in the top of your code for the library, which will call in the definition files and thus add the usable functions to your project.


    Changelog
    5/28/2011 - Fixed the overwritten images, whoops. Thanks Cyan.

    5/23/2011 - Added .c files to the association, added descriptive intro.
    5/12/2011 - Added basic info on additional libraries, using Nightfox's lib as the example.
    5/12/2011 - Fixed a typo, added batch file to compile.
    5/11/2011 - Initial version.
     
    NewJoarpa, Tejomaru and jimmyemunoz like this.


  2. SamAsh07

    Member SamAsh07 GBAtemp Addict

    Joined:
    Jan 27, 2009
    Messages:
    2,693
    Location:
    Bahrain
    Country:
    Bahrain
    The hell is this?? I never heard of it :wtf:

    I'm sure it'll be useful to those techy ppl out there...nice unique guide.
     
  3. Zorua

    Zorua Newbie

    It's for homebrew developers.
     
  4. jurassicplayer

    Member jurassicplayer Completionist Themer

    Joined:
    Mar 7, 2009
    Messages:
    4,280
    Location:
    Pantsuland
    Country:
    United States
    :/ I dunno if it's really much help if you know where to look (the actual website pretty tells you everything to do already). I mean the installer does most of everything...then you could just use either programmer's notepad or just a preferred plain text editor...Apart from that, you just have a cmd open to the folder and type "make" and it will compile the homebrew...supposing you don't have some flaw in the homebrew or the makefile. IIRC I think PN also has a shortcut for compiling...or maybe I'm thinking of Notepad++ or something else...
     
  5. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    If you're saying that a tutorial's not going to help somebody who already knows what they're doing... if everybody knew that they were doing we'd have a lot less people begging for patches and homebrews, and a lot more people making them.

    I sure as hell didn't know where to look when I started on the DS. Most of the tutorials I found through googling were outdated, referencing tools that wouldn't work with each other any more or that I couldn't find, or were only for 2K/XP. Just because somebody can code doesn't mean they have an environment like this set up, or have set one up before. I've only worked with interpreted languages, so I never even compiled anything until I started tinkering with the DS. The only environment I had ever set up was a local install of XAMPP, which is nothing like this... and there are people who have always coded in an environment that already had an interpreter (such as work or a class), so they hadn't even done that much (not to mention the people who first got into programming via Game Maker or something like that). Setting up an environment and compiling is probably foreign to them, as it was to me.

    I don't know how much programming you've done, but there's a hell of a lot more out there than C/++, so there's going to be a lot of people who can at least somewhat code, but just need info on how to set up the tools and such.

    You're probably thinking of PAlib that adds batch files to project folders for quick access to compiling, but some reputable people including Normmatt recommend against PAlib so I didn't include it. I'll probably try nightfox's lib out later and add info on how to use that, as an example on how to add libraries... which is again, not something that's always done in programming. I went with PHP for a year or two before I ever included an external library, for example.
     
  6. Mazor

    Member Mazor Z80 master arch

    Joined:
    Feb 14, 2008
    Messages:
    547
    Country:
    Sweden
    Decent guide, no other complaints

    Edit: derpgarmmarspelling.
     
  7. jurassicplayer

    Member jurassicplayer Completionist Themer

    Joined:
    Mar 7, 2009
    Messages:
    4,280
    Location:
    Pantsuland
    Country:
    United States
    Lol, the devkitpro website that you MUST visit has the tutorials that I was talking about xD (at least...they looked pretty easy to follow the last time I read them).
    I actually know shit about coding. The only things I know are shoddy html, shoddy CSS, and a shoddy use of variables in RPGMaker. With that said, I get by with compiling stuff to work the way I want somehow (seriously I have no idea how html/CSS have anything to do with it though...)...abeit tedious, messy, and definitely could be optimized.

    I don't think I ever figured out how to do things correctly with PAlib the last time I tried xD...though I didn't put much effort into it anyways. I'm pretty sure I'm thinking about Notepad++ then if it's not in PN. Notepad++ is actually a really awesome text editor for this sort of stuff (preferences come first)...not that I use it on Ubuntu :/.
     
  8. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    I kept finding mirrors, as the "installer" you download is a small file as it just downloads the required tools, so people felt alright with mirroring it... and when I googled it all I found was the forums, and at the time I didn't find anything there about actually getting it.

    If you're looking on how to program, I'll be adding a big repository to information a couple professionals I know have made.
     
  9. boktor666

    Member boktor666 Gbatemp's official Solar Boy™ Is Back!

    Joined:
    Jun 16, 2010
    Messages:
    805
    Location:
    Holland, somewhere :D
    Country:
    Netherlands
    There is also the equivalent of this program, called Palib, wich can also be very very usefull to homebrew creators. Mabey you can add it, as it is used very widley over the scene. DevKit and Palib are both awesome compliers.
     
  10. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    PAlib is an additional library (a separate thing from this, in fact it's an add-in), but multiple high-profile coders in the DS scene recommend against it's use (and it's dead anyways).
     
  11. boktor666

    Member boktor666 Gbatemp's official Solar Boy™ Is Back!

    Joined:
    Jun 16, 2010
    Messages:
    805
    Location:
    Holland, somewhere :D
    Country:
    Netherlands
    Hmm, how come its dead, did the developers stop or something? I heard of homebrew still using it... ah well.. nvm then [​IMG]
     
  12. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    Yeah it stopped last July.
     
  13. Costello

    Administrator Costello Headmaster

    Joined:
    Oct 24, 2002
    Messages:
    12,030
    I think you got a nice guide here but you should indicate what it's for.
    Perhaps a short introduction telling people what this is about and why you've chosen to write a tutorial about this.
     
  14. SifJar

    Member SifJar Not a pirate

    Joined:
    Apr 4, 2009
    Messages:
    6,022
    Country:
    United Kingdom
    You mentioned adding .cpp and .h to PN2's associated files. You should also add .c files IMO, many homebrews include them, so if you're editing them/looking for inspiration from them, they are useful to have there.
     
  15. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    M'kay, did both of those.
     
  16. Wawslininig

    Newcomer Wawslininig Newbie

    Joined:
    Dec 15, 2011
    Messages:
    5
    Country:
    United States
    Haha that's rediculous. No way
     
  17. TheDreamLord

    Member TheDreamLord GBAtemp Advanced Fan

    Joined:
    Jun 8, 2011
    Messages:
    924
    Location:
    Ireland
    Country:
    Ireland
    compiler doesn't work. Using windows 7 32 bit.
     
  18. Rydian
    OP

    Member Rydian Resident Furvert™

    Joined:
    Feb 4, 2010
    Messages:
    27,883
    Location:
    Cave Entrance, Watching Cyan Write Letters
    Country:
    United States
    What happens when you try to run it?
     
  19. TheDreamLord

    Member TheDreamLord GBAtemp Advanced Fan

    Joined:
    Jun 8, 2011
    Messages:
    924
    Location:
    Ireland
    Country:
    Ireland
    Press any key to continue . . .

    C:\devkitPro\examples\nds\hello_world>cd
    C:\devkitPro\examples\nds\hello_world

    C:\devkitPro\examples\nds\hello_world>make
    'make' is not recognized as an internal or external command,
    operable program or batch file.

    C:\devkitPro\examples\nds\hello_world>pause
    Press any key to continue . . .
     
  20. Foxi4

    Reporter Foxi4 On the hunt...

    pip
    Joined:
    Sep 13, 2009
    Messages:
    22,705
    Location:
    Gaming Grotto
    Country:
    Poland
    Uninstall and Install the toolchain, it appears that the installer didn't register "make" as a command.
     

Share This Page