DS Programming Environment On Windows

-

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).
    01.gif


    dspro_01.gif
  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.
    dspro_02.gif


    dspro_03.gif


    dspro_04.gif
  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.
    06.gif
  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.
    07.gif


    08.gif


    09.gif


    10.gif



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.
    11.gif


    12.gif


    13.gif


    14.gif
  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!
    20.gif
  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.
    18.gif



(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.
 

SamAsh07

Well-Known Member
Member
Joined
Jan 27, 2009
Messages
2,696
Trophies
0
Age
33
Location
Bahrain
XP
601
Country
Bosnia and Herzegovina
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.
 

jurassicplayer

Completionist Themer
Member
Joined
Mar 7, 2009
Messages
4,484
Trophies
1
Location
Pantsuland
Website
www.youtube.com
XP
2,894
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...
 

Rydian

Resident Furvert™
OP
Member
Joined
Feb 4, 2010
Messages
27,880
Trophies
0
Age
36
Location
Cave Entrance, Watching Cyan Write Letters
Website
rydian.net
XP
9,111
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.
 

Mazor

Z80 master arch
Member
Joined
Feb 14, 2008
Messages
547
Trophies
0
Age
16
Website
Visit site
XP
245
Country
Zorua said:
SamAsh07 said:
The hell is this?? I never heard of it :wtf:

It's for homebrew developers.

No, homebrew developers per definition already have this or an equivalent setup already if they are homebrew developers. This is for non-homebrew developers (such as people with experience in programming languages but without homebrew development experience) who are interested in looking into homebrew development or people who might just want to test something.


As for the guide: You should probably mention that any text editor can be used rather than only referring to the included PN. The installation of the registry hack that you suggest is a pretty iffy solution for simple compilation. A simple batch script such as
@echo off cd %1 make echo Build completed. pause
that you can just drop the folder with the project you want to compile on, or a similar script, would be a much better alternative. I would really suggest either putting a ready .bat file of this kind or instructions on how to make one in your guide as a replacement for the registry hack.

Also, QUOTE(Rydian @ May 12 2011, 03:11 AM)
Close Programmer's Notpad.

Decent guide, no other complaints

Edit: derpgarmmarspelling.
 

jurassicplayer

Completionist Themer
Member
Joined
Mar 7, 2009
Messages
4,484
Trophies
1
Location
Pantsuland
Website
www.youtube.com
XP
2,894
Country
United States
Rydian said:
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 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.
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 :/.
 

Rydian

Resident Furvert™
OP
Member
Joined
Feb 4, 2010
Messages
27,880
Trophies
0
Age
36
Location
Cave Entrance, Watching Cyan Write Letters
Website
rydian.net
XP
9,111
Country
United States
Mazor said:
As for the guide: You should probably mention that any text editor can be used rather than only referring to the included PN.I mentioned Notepad++ as well. The only other one I've used is Notepad2, which is eclipsed by Notepad++ in all the ways I know of so I didn't mention it. Got any others to add?

Mazor said:
The installation of the registry hack that you suggest is a pretty iffy solution for simple compilation.It's an official "powertoy" from microsoft, I chose that because I couldn't get a batch file working with certainty.

Mazor said:
A simple batch script such as
@echo off cd %1 make echo Build completed. pause
that you can just drop the folder with the project you want to compile on, or a similar script, would be a much better alternative. I would really suggest either putting a ready .bat file of this kind or instructions on how to make one in your guide as a replacement for the registry hack.Awesome, I'll toss up a mediafire link to that, thanks.

Mazor said:
Also, QUOTE(Rydian @ May 12 2011, 03:11 AM) Close Programmer's Notpad.
Oops.

Know of any other ways this could be expanded, other than a quick snip on adding additional libraries?

QUOTE(jurassicplayer @ May 12 2011, 06:39 AM)
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 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.
 

boktor666

Gbatemp's official Solar Boy™ Is Back!
Member
Joined
Jun 16, 2010
Messages
807
Trophies
0
Age
29
Location
Holland, somewhere :D
XP
285
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.
 

Rydian

Resident Furvert™
OP
Member
Joined
Feb 4, 2010
Messages
27,880
Trophies
0
Age
36
Location
Cave Entrance, Watching Cyan Write Letters
Website
rydian.net
XP
9,111
Country
United States
boktor666 said:
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.
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).
 

boktor666

Gbatemp's official Solar Boy™ Is Back!
Member
Joined
Jun 16, 2010
Messages
807
Trophies
0
Age
29
Location
Holland, somewhere :D
XP
285
Country
Netherlands
Rydian said:
boktor666 said:
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.
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).
Hmm, how come its dead, did the developers stop or something? I heard of homebrew still using it... ah well.. nvm then
smile.gif
 

Costello

Headmaster
Administrator
Joined
Oct 24, 2002
Messages
14,201
Trophies
4
XP
19,704
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.
 

SifJar

Not a pirate
Member
Joined
Apr 4, 2009
Messages
6,022
Trophies
0
Website
Visit site
XP
1,175
Country
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.
 

TheDreamLord

Well-Known Member
Member
Joined
Jun 8, 2011
Messages
939
Trophies
0
Age
24
Location
Ireland
Website
darkraino1.zymichost.com
XP
476
Country
Press any key to continue . . .
What happens when you try to run it?


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 . . .
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,824
Trophies
3
Location
Gaming Grotto
XP
29,817
Country
Poland
Press any key to continue . . .
What happens when you try to run it?


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 . . .
Uninstall and Install the toolchain, it appears that the installer didn't register "make" as a command.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Sonic Angel Knight @ Sonic Angel Knight: :ninja: