Difference between revisions of "Nintendo DS"

From Lazarus wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
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 =
  
= Nintendo DS port =
+
== History ==
 +
NDS 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.
  
 
== Status ==
 
== Status ==
*The 2.2.0 compiler officially supports Nintendo DS.
+
*All fpc major features are fully supported
*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.
 
*ASM THUMB mode is not supported yet.
*Base RTL is working
+
*The compiler is built for Win32 and Linux
  
 
== Port notes ==
 
== Port notes ==
(''This wiki refers to 2.3.x branch, that is downloadable from [ftp://ftp.freepascal.org/fpc/snapshot/trunk/arm-nds/arm-nds-fpc-2.3.1.i386-win32.zip freepascal's ftp]'')
+
Nintendo DS can run executables made for ARM9 and/or ARM7 cpu. It is possible to switch between ARM9 and ARM7 by using
 
 
Nintendo DS can run executables made for ARM9 and/or ARM7 cpu. It is possibile to switch between ARM9 and ARM7 by using
 
 
<pre>{$apptype arm9}  
 
<pre>{$apptype arm9}  
 
and
 
and
Line 23: Line 20:
 
=== Why .nef and .nlf? ===
 
=== 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.
 
.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? ==
 
== What I need to start coding for  Nintendo DS? ==
* [ftp://ftp.freepascal.org/fpc/snapshot/trunk/arm-nds/arm-nds-fpc-2.3.1.i386-win32.zip Free Pascal for Nintendo DS]
+
* [http://www.freepascal.org/down/arm/nds.var Free Pascal for Nintendo DS]
 
* [http://devkitpro.org/ devkitARM] toolchain
 
* [http://devkitpro.org/ devkitARM] toolchain
 
* [http://devkitpro.org/ libnds]  
 
* [http://devkitpro.org/ libnds]  
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
 
  
  
Line 35: Line 30:
 
(''All these docs are aimed to C/C++ language'')
 
(''All these docs are aimed to C/C++ language'')
 
* [http://www.dev-scene.com/NDS/Developers Dev-Scene tutorials]: some good tutorials about Nintendo DS programming.
 
* [http://www.dev-scene.com/NDS/Developers Dev-Scene tutorials]: some good tutorials about Nintendo DS programming.
* [http://patater.com/manual 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.
+
* [http://patatersoft.info/manual.php 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.
 
* [http://www.coranac.com/tonc/text/toc.htm 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.
 
* [http://www.coranac.com/tonc/text/toc.htm 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.
 
* [http://www.double.co.nz/nintendo_ds/index.html Homebrew Nintendo DS Development]
 
* [http://www.double.co.nz/nintendo_ds/index.html Homebrew Nintendo DS Development]
Line 42: Line 37:
  
 
== Tools ==
 
== Tools ==
 +
* [http://desmume.org DeSmuME emulator]: a pretty good NDS emulator. The emulator has some debugger functions and it implements a GDB stub mechanism.
 
* [http://nocash.emubase.de/gba.htm 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.
 
* [http://nocash.emubase.de/gba.htm 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.
 
* [http://www.ideasemu.org/ 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.
 
* [http://www.ideasemu.org/ 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.
  
 +
== Using Lazarus for Nintendo DS development ==
 +
A fpc 2.4.0 based distribution of Lazarus is needed.
 +
*Select ''Project->New project->Program''
 +
*Modify the code removing the unneded parts:
 +
<syntaxhighlight lang=pascal>
 +
program Project1;
 +
{$mode objfpc}
 +
uses
 +
  ctypes, nds9;
 +
 +
begin
 +
 +
end.
 +
</syntaxhighlight>
 +
 +
*From the menu ''Project->Project options...->Compiler options'' select "NoGUI" as LCL widget type
 +
*Move on ''Compiler options->Code'' then select "arm" as Target CPU and "nds" as Target OS
 +
*Move on ''Compiler options->Other'' then check "Use additional Compiler Config file", writing the config file of your nds compiler (maybe something like c:\lazarus\fpc\2.4.0\bin\arm-nds\fpc.cfg). Lazarus will complain about some conflicting names, but just do ok and all will be fine
 +
*From the menu ''Run->Run parameters...->Local->Host Application'' select your emulator with full path (something like c:\desmume\desmume.exe)
 +
*Put $ProjPath()\$NameOnly($ProjFile()).nds on "Command line parameters" field
 +
 +
'''What works''': Code completion and all code related features (tooltips, refactoring, ...)
 +
 +
'''What DOES NOT work''': the debugger (use the debugger on the emulator); the LCL (you can't make applications in the visual way. The NDS coding is somewhat similar to console application programming)
  
 
== Links ==
 
== Links ==
Line 52: Line 72:
 
* [http://www.pascalgamedevelopment.com Pascal Game Development]: the biggest pascal game development community.
 
* [http://www.pascalgamedevelopment.com Pascal Game Development]: the biggest pascal game development community.
 
* [http://www.devkitpro.org devkitPro]: the home page of the GBA, NDS, Gamecube, GP32 and PSP development toolkit.
 
* [http://www.devkitpro.org devkitPro]: the home page of the GBA, NDS, Gamecube, GP32 and PSP development toolkit.
 +
 +
[[Category: Video Game Consoles]]
 +
[[Category: Operating Systems and Platforms]]
 +
[[Category: ARM]]

Latest revision as of 09:16, 21 February 2020

Nintendo DS port

History

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

Status

  • All fpc major features are fully supported
  • ASM THUMB mode is not supported yet.
  • The compiler is built for Win32 and Linux

Port notes

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

{$apptype arm9} 
and
{$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?


Documentation

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

Tools

  • DeSmuME emulator: a pretty good NDS emulator. The emulator has some debugger functions and it implements a GDB stub mechanism.
  • 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.

Using Lazarus for Nintendo DS development

A fpc 2.4.0 based distribution of Lazarus is needed.

  • Select Project->New project->Program
  • Modify the code removing the unneded parts:
program Project1;
{$mode objfpc}
uses
  ctypes, nds9;

begin

end.
  • From the menu Project->Project options...->Compiler options select "NoGUI" as LCL widget type
  • Move on Compiler options->Code then select "arm" as Target CPU and "nds" as Target OS
  • Move on Compiler options->Other then check "Use additional Compiler Config file", writing the config file of your nds compiler (maybe something like c:\lazarus\fpc\2.4.0\bin\arm-nds\fpc.cfg). Lazarus will complain about some conflicting names, but just do ok and all will be fine
  • From the menu Run->Run parameters...->Local->Host Application select your emulator with full path (something like c:\desmume\desmume.exe)
  • Put $ProjPath()\$NameOnly($ProjFile()).nds on "Command line parameters" field

What works: Code completion and all code related features (tooltips, refactoring, ...)

What DOES NOT work: the debugger (use the debugger on the emulator); the LCL (you can't make applications in the visual way. The NDS coding is somewhat similar to console application programming)

Links