Nintendo DS

From Lazarus wiki
Revision as of 21:19, 8 January 2008 by Legolas (talk | contribs) (Nintendo DS port)

NDS port is still in heavy development, but is gaining progress rather quickly. Port began and was created by Francesco Lombardi with the knowledge gained from the making of the GBA port. This endeavor is an extension of the original goals of the FPC 4 GBA project.

Nintendo DS port


  • The 2.2.0 compiler officially supports Nintendo DS.
  • The 2.3.x branch introduces some eavy changes (new memory manager, new intermediate files)
  • ARM7 and ARM9 CPU are supported.
  • ASM THUMB mode is not supported yet.
  • Base RTL is working

Port notes

(This wiki refers to 2.3.x branch, that is downloadable from freepascal's ftp)

Nintendo DS can run executables made for ARM9 and/or ARM7 cpu. It is possibile to switch between ARM9 and ARM7 by using

{$apptype arm9} 
{$apptype arm7}

That generates .nef.bin and .nlf.bin binaries. If not specified, fpc assumes arm9 as default apptype and, in this case, calls ndstool.exe (a tool you can find as part of devkitPro) in order to generate a patched binary with .nds extension. This file should work on your hardware/emulator. In case of an arm7/arm9 mixed program, it is necessary to compile separately arm7 and arm9 code, then convert the .nef.bin and .nlf.bin binaries with ndstool.exe in this way:

ndstool -c myprog.nds -9 myprog.nef.bin -7 myprog.nlf.bin

The current NDS port is tested and reported as working with the latest devkitPro arm-eabi binutils.

Why .nef and .nlf?

.nef means "not executable file" and it is the extension that no$gba debugger uses for loading arm9's synmbolic debug infos from. In the same way it loads arm7's debug infos from .nlf files.

What I need to start coding for Nintendo DS?

The Free Pascal for Nintendo DS package comes with bindings, libraries and examples and should work out of the box. Please refer to the readme file in order to set the right paths in the fpc.cfg file


(All these docs are aimed to C/C++ language)

  • Dev-Scene tutorials: some good tutorials about Nintendo DS programming.
  • Patater's manual: a manual that covers topics including the legality of homebrew and the politics behind it, displaying backgrounds on both screens, sprites, and a bit of game mechanics.
  • TONC tutorial: this is a tutorial aimed to Gameboy Advance programming, but it is perfectly adaptable to Nintendo DS. You can find a lot of tricks about optimizing your code too.
  • Homebrew Nintendo DS Development
  • The DS Wiki a Wiki aimed to Nintendo DS programming.
  • GBATEK: GBA and NDS technical infos. THE Bible!


  • No$GBA emulator: at this time, it's the best NDS and GBA emulator. The emulator itself is freeware; for 15$ you can get the debugger.
  • iDeaS emulator: another good emulator. Though its level is not comparable to no$gba, it comes for windows and linux too, and has some debugger funcs.