このチュートリアルは3つのパートに分かれています :
ここでは PAlib のインストール方法について詳細に解説します。Visual Studio C++ の設定についても触れます。 さらに Linux 環境へのインストール と Mac OS X 環境へのインストール (要更新) についても紹介しています。PAlib テンプレートと makefile を理解する は OS にかかわらず、 PAlib ユーザ必読です。
このガイドは手っ取り早く devkitPro と Palib のインストール方法を知りたい人向けです。より詳細なインストール手順はこちらへどうぞ。
まず主要な DS 開発環境を整えるために、 the devkitPro Updater を使って devkitARM (とその他いろいろ) をダウンロードしてインストールしなければなりません。
気を付けてください! devkitPro Updater はデフォルトで DS 以外の PSP, GBA, GP2X などに必要な環境やライブラリもインストールしてしまいます。これらが不要な場合はチェックをはずしてください。DS 開発に最低限必要なものは msys, devkitARM, libnds だけです。
訳注: devkitPro Updater は devkitPro Updater プログラムが置かれているフォルダに一時ファイルをばらまきます。デスクトップに置いた状態で実行すると悲惨なことになるので、何かフォルダを作ってその中で実行すると良いでしょう。
アップデータを実行すると C:\devkitPro は次のようなフォルダ構成になっているはずです:
C:\DevKitPro\ + devkitARM + devkitPPC (オプション) + devkitPSP (オプション) + examples + insight (オプション) + libgba (オプション) + libmirko (オプション) + libnds + libogc (オプション) + msys + Programmers Notepad (オプション)
PAlib は devkitARM リリース22またはそれ以降のバージョンに完全対応しているわけでばありません。そのため devkitARM のバージョンを リリース21に落とす必要があるかもしれません。devkitPro Updater によってインストールされた “devkitARM” フォルダを “devkitARM_r23” に名前を変更するか削除するかしたあと、devkitARM リリース21 をダウンロードして C:\devkitPro に解凍してください (フォルダ名を “devkitARM” にして置き換える )。
次に PAlib を the PAlib Installer からダウンロードしてインストールしてください。PAlib のインストールは devkitARMと同じ階層に中身を解凍するだけです。別のフォルダにインストールすることも可能ですが、そうする必要のある場合はインストーラに含まれる readme を参照してください。
[訳注] 実際に試したところ、zipを解凍しただけでは当然のことながら環境変数 PAPATH が追加されないため、ビルドに失敗しました。そのため PAPATH という名前で PAlibのパスを環境変数として追加してください。もしくはMakefileに記述してもかまいません。インストーラを使っても環境変数の追加は確認できませんでした。
注意してください! devkitPro や PAlib を空白文字を含むフォルダ (例えば “c:\DS Development\PA Lib\” のような) にインストールすることはできません。よってデスクトップにインストールしても動かないでしょう。デスクトップのフルパスは “c:\Documents and Settings\...” のようになるためです。
PAlib は部分的に .NET Framework を必要とするためインストールしておく必要があります。.NET Framework を必要とするのは PAGfx (グラフィックコンバータ), PAFS (ファイルシステム), VHam (統合開発環境)です。ここからインストールしてください。
これでインストールが終わりました! PCを再起動して次のテストコンパイルにすすみましょう!
[訳注] PAlibはバージョンによって関数名が違うことがあるため、バージョンを変更する際には注意が必要です。
開発環境が正しくインストールされているかどうか確かめる方法はたくさんありますが・・・難しくないので、うまく動作することを願ってやってみましょう!
サンプルプログラムをコンパイルしてみましょう。palib\examples\Text\Normal\Helloworld\ を開いて build.bat をダブルクリックします。そうするとビルド処理が始まり(コマンドプロンプトに進捗が表示される)、全てうまくいけば helloworld.ds.gba と helloworld.nds が生成されます。
GetIPCとスタティック宣言について大量の警告 (warning) が表示された場合は devkitARM リリース21をインストールする必要があります。インストール手順に詳細な記述があります。
この Hello World プログラムがエラーなしでコンパイルできたなら次のセクションに進んでもかまいません。しかしインストールしたライブラリや DS 開発に慣れ親しむためにもこれ以降の部分も読むことを勧めます。
正しく動作する開発環境と PAlib を手に入れたあなたは、今すぐにでもコーディングを始めたいことでしょう。でもその前に \PAlib\template\ フォルダにある PAlib テンプレートについて少し知っておいた方がよいでしょう。ここでは PAlib テンプレートがどのように動くのかについて少し解説したいと思います。
えーっと、以前にも聞かれたことがある・・・テンプレートって何? うん、テンプレートはプログラムのための基盤となる部分やその構造を提供する仕組みです。つまりあなたはその空っぽの構造に C/C++ のコードや画像ファイル、音楽ファイルなどを追加するわけです。正しく構成されたテンプレートを使っているので、あなたは簡単に NDS ファイルをコンパイルできるでしょう。
これが PAlib テンプレートの構造です:
フォルダ :
ファイル :
それでは project.vhw (VisualHam) または template.pnproj (Programmer’s Notepad), もしくはあなたの好きなエディタで “source” フォルダの中の main.c を開いてください。名前からもわかるように、main.c はプログラムの起点となるファイルです。それは main() 関数と ROM 起動時に必要な全てのものを含んでいます。テンプレートの main.c は PAlib を動かすために必要最低限のものを含みます。これをそのままコンパイルして実機の DS やエミュレータで動かしてみても、ディスプレイには真っ白な画面になるだけで何も起きないでしょう。それは基本的な初期化以外はなにもしていないからです。
これが main.c の最初の状態です:
// ヘッダインクルード #include <PA9.h> // PA_Lib のインクルード // 関数: main() int main(int argc, char ** argv) { PA_Init(); // PA_Lib の初期化 PA_InitVBL(); // 標準 VBL の初期化 // プログラムを走らせるための無限ループ while (1) { PA_WaitForVBL(); } return 0; } // main() の終了
もしあなたがすでに C プログラミングに親しんでいるのであればこれらはあたり前のことでしょう。しかしそうでない人のために1行ずつ十分なコメントとともに解説したいと思います。
// ヘッダインクルード
// はその行のそれ以降の文字列をコメントとして見なし、コンパイル時に無視してもらうように指示します。ここでは「この部分でヘッダ読み込みをしていますよ」ということを読む人に伝えるために書いています。
#include <PA9.h>
これは「PAlib をこのプログラムに読み込んで(インクルードして)ください」という意味があります。これがないと PAlib は認識されず、コンパイル時にエラーが出るはずです。インクルードは画像ファイルやその他のプログラムを追加する際にとても重要なことになります。
int main(int argc, char ** argv)
このよくわからないものはどのプロジェクトにも必ず1つあります: これはプログラムの開始点で、全てはここから始まります。(int argc, char argv) が一体なんなのかについて頭を悩ませないでください。実行されるコードは ‘{’ 以降にあります :)
PA_Init(); // PA_Lib の初期化 PA_InitVBL(); // 標準 VBL の初期化
PAlib を使用する多くのプロジェクトでこの2行を見付けることができます。1行目は一般的な初期化です。それはスプライト、背景、テキスト表示など全ての準備を行います。これがないと PAlib はまともに動きません。’VBL’ という文字列の付いた2行目は、より高度な使い方をするユーザに限って必須ではありません。簡単に言うと VBL はプログラムを画面描画の毎秒60フレームに同期させます。VBL 初期化をしない場合、プログラムは高速 (実際には描画不可能な毎秒100000フレームなど) で動作するか、まったく動作しないことになります(最初のフレームで止まる)。通常はこれらの2つの関数呼び出しはそのまま残しておいてください。
// プログラムを走らせるための無限ループ while (1)
while ステートメントは結果(ここでは1となってる部分)が0以外である限りそれに続くコードブロック(中括弧で囲まれた部分)を繰り返し実行します。ここでは常に1になっているため、永久に繰り返すことになります。何のために? それはもしこのようなループを持たない場合、プログラムは全ての行を1度だけ実行して、それ以上何も表示せず終了してしまいます。つまりユーザが電源ボタンを押すなどして終了させるまでプログラムを動作させつづける意味があります。考え方としてはこのループの中でプログラムは画面に表示するために必要な全ての計算をしそれを描画します。
PA_WaitForVBL();
最後のコードは FPS (1秒間あたりの描画回数) をちょうど60に同期するための関数です。これを実行しないと前述のように超高速で描画されるかまったく動かないでしょう。
} return 0; } // main() の終了
ここでコードを終了します。常にここにあって、常にこんな風に書いてあります。あまり深く悩まずそっとしておいてください :P
以上でテンプレートの全てを理解できました。それでは次に進んでディスプレイに文字列を表示する方法について学びましょう!
それではテンプレートに手を加えて単純な Hello World プログラムを作ってみましょう。ここではまだ DS プログラミングの詳細には立ち入らず、これまでの内容だけでもこんなに簡単にできるということを示すためのものです :P
Hello World プログラムを作るために PAlib の基本的なテキスト描画システムを使います。テキスト描画システムは1枚の背景 (ちなみに1画面あたり4つの背景を持っています) を使い、どの背景を使うか選ぶことができます。テキストのフォント設定、フォント色設定、といった具合に非常に多くの関数が用意されていますが、ここではあまり凝らずに簡単にいきます :P
何かしたいときはテンプレートの main.c ファイルの PA_InitVBL() 行の後に追加してください。
PA_InitText(1, 2); // 画面1に背景2を設定 PA_OutputSimpleText(1, 1, 1, "Hello World !"); // 画面1の座標(1, 1)に指定されたテキストを描画
最初の1行でテキスト描画システムを初期化(フォントをVRAMに読み込む)します。これをしないとテキストはノイズのようなゴミみたいに描画されるでしょう・・・。PA_InitText は2つの引数を取ります:
PA_OutputSimpleText は名前からもわかる通り、(事前に PA_InitText で初期化してあれば)テキストを画面に出力します。(ここで PAlib の関数は全て “PA_” で始まるのではないかと気付いた方もいるでしょう・・・) OutputSimpleTextは4つの引数を取ります:
[訳注] つまり標準フォントを使った場合1行の高さが8ピクセルなので、32文字を24行表示できるわけです。
VisualHamを使っているのなら F6 でコンパルして DualiS エミュレータで起動、F7 はコンパイルして DeSmuME エミュレータで起動、F5 はコンパイルのみになります。便利なので覚えておいてください! もちろん build.bat をダブルクリックしても OK です。
Original tutorial by Rodrigo Sieiro revised for VC++ 2008 by Christian Crawford
As a developer, I work with Visual Studio every day. So, when I decided to start programming for NDS, I found myself trying a lot of different IDEs, hoping to find the features I had in Visual Studio. I tried Programmers Notepad, VisualHAM, EditPlus, PSPad, and so on. No one seemed to satisfy me.
So I started researching how could I use the (free) Visual C++ 2008 Express with PALib. And I learned a few things from different places: a little in PALib’s French Wiki (I don’t read French, just followed the figures), a little in devkitPro’s FAQ, until I could manually make a PALib project inside Visual C++. Then I found OGRE’s (a 3D Engine) AppWizard for VCExpress, so I tweaked my base project a bit and made it an AppWizard.
In this guide I’ll explain how you can set up a fully working development environment with Visual C++ 2005 Express and PALib. As you can see in the image above, here are some features you can expect by using this method:
Before you begin, make sure you already installed the following stuff:
Follow the installation guide above to be sure you can at least compile and run a basic project (using any editor and “make” command line), so you can be certain that your basic environment is configured correctly before configuring Visual C++ Express.
Important: I suggest you to install PALib inside devkitPro folder, because the AppWizard (code completion, mainly) probably won’t work if you install it in a different place.
When you install devkitPro and PALib, they already add some environment variables for you. But these variables are for the make tool, so the path names are written in “UNIX Style”. So, in order to compile PALib and devkitPro inside Visual Studio, first we need to set a new Environment Variable.
Open “Start → Settings → Control Panel → System”. Select “Advanced” then click on “Environment Variables”. Click on the “New” button inside “System Variables” (the lower one) and add a variable with the name “DKP_HOME”. In the “Value” box, write the root folder of your devkitPro installation, “Windows Style” (i.e. “c:\...” instead of “/c/...”).
If running Windows Vista you will need Admin rights and you go “Start → control panel → system” then click on the “change settings” it will open the window above and click “Advanced”
Get the AppWizard here or alternatively you can download NightFox’s version which is installed the same way and include his libraries (eg: EFS) here Now let’s install the PALib AppWizard. Extract the contents of the ZIP file inside a PERMANENT folder. The template files will stay there and can’t be removed, otherwise you will break your AppWizzard. I recommend using a folder called “PALibAppWizard” inside devkitPro root folder, so it sits together with “PALibExamples” and “PALibTemplate”. That’s what I use.
After you extract the contents, you will see two JavaScript files: “VC9_Express_Setup.js” and “VC9_Setup.js”. As you probably figured, the first is for Visual C++ 2008 Express and the second is for other versions of Visual C++ 2008. Double-click the one corresponding to your version and it will install the wizard automatically. I only have Visual C++ 2008 Express, so don’t blame me if the wizard doesn’t work with VC++ 2008 Pro. I can’t test it. From DtD Software: I have tested the script with Microsoft Visual Studio 2008 Pro and it works like a charm.
If everything went well, you will see the following message:
If running Windows Vista you will see the message above but it wont install properly. manually copy the files explained below.
If your .js files are registered to another program, such as Dreamweaver, the previous method won’t work (the script will open inside the editor, and won’t run). If that’s your case, you can run the .js script manually, via the Run box. Click on Start then Run and type:
WScript.exe <location of setup js>
The location above should be the full path and filename of the .js file you need to use. That should work.
If you are afraid that I put inside the .js some ultra-power virus that will explode your monitor and erase all DVDs up to 1 mile far from your computer, you can manually copy the AppWizard files to their location. Follow this steps:
That’s it, your AppWizard is installed. Now follow the rest of the guide to setup some more things in your Visual Studio.
Open Visual C++. Before you rush on clicking “New Project” to see PALib there, let’s do one more thing that will be very helpful. Since the “make” tool we use to compile PALib project doesn’t like long filename and directories with spaces, I suggest you to change your default “Projects” folder inside Visual C++ so you won’t have to change it everytime you create a new project.
Go to “Tools”, then “Options”, then “Projects and Solutions”, then “General”. Change the field “Visual Studio Projects Location” to a folder with no spaces. I suggest something short, like I used in the picture below.
Now you can click on “File” → “New” and select “New Project”. If you installed the AppWizard correctly, you will see a new “NintendoDS” category, and inside it, you have the “PALib Application” wizard. This is a pre-configured project, with all the things you need to do in order to compile PALib project inside Visual C++ already configured for you. Type a Project Name, check the “Location” to be sure you don’t have a directory with spaces, and click “OK” to start the wizard.
There’s not much stuff you can change in the wizard. I tried to think about some options I could put there but my creativity wasn’t cooperating with me when I wrote the wizard. The first screen is an overview of the project you are creating. Click on “Next” when you are ready to proceed.
In the second page, you can choose between “Standard application” and “Minimal application”. “What’s the difference?”, you may ask. Simple: the last one is the very minimal you need in order to build a PALib project. You can compile and run its generated application, but it won’t do anything. The first is a fully functional “Hello World” application, with two more lines of code that actually do something. Now that’s a huge difference! Click on “Finish” to generate your project.
Now let’s check out the files that were generated by the wizard:
Notice how Visual Studio can organize your project by content type... That’s even better when you have a lot of files inside your project!
I’ve tweaked the default PALib Makefile (found in the PALibTemplate) so it can work better with Visual Studio. This way, you can use all the build options Visual Studio offers: “Build”, “Rebuild” and “Clean”. Rebuild is actually the same as selecting “Clean” then “Build”.
Okay, we’re set, let’s try building our project for the first time. Click on “Build” then “Build Solution”, or press F7. Visual C++ will start compiling your project using the Makefile. You can see what’s it doing in the “Output” window. It will compile all your source files, link them in a binary file, and then call the tools that generate three files for you: a “.nds”, a “ds.gba”, and a “.sc.nds”. These files will be generated in the “Release” subfolder of you Project. If the last line in the Output window says “Build: 1 succeeded”, then everything went well. If you didn’t touch the code and get an error, you’re screwed. So you should delete DevKitPro and PaLib and then install it again and following the stpe from the start making sure to not miss out anything.
NOTE: For Windows Vista users, go to Project → [projname] Properties. Expand the “Configuration Properties” tree on the left bar and go to NMake. Click on the “Build Command Line” field and a little box with ... in it should appear on the right. Click that to bring up a text area to type out the commands. Insert a new line before what’s already there and add “set PATH=C:\devkitPro\devkitARM\bin;C:\devkitPro\devkitARM\arm-eabi\bin;C:\devkitPro\devkitARM\libexec\gcc\arm-eabi\4.1.1;%PATH%” to it (without the quotes). Save it and you should be able to compile correctly. I got some errors in a couple sound headers from PALib about incorrect conversions from void pointers to u32 pointers. If you double click on the error, it will take you to the line. Add a (u32*) to the line so it’s like “blahblah = (u32*)blaghblagangjklaglk;” on both lines that have the error. After that, the compile worked like a charm for me and NO$GBA read the file just fine. – Ari Velazquez (arivelz@gmail.com)
Lastly, don’t forget to set up Visual C++ directory variabiles in order to get IntelliSense to work with the PALib! Go to Tools → Options → Project & Solutions → VC++ Directories, then select “Include files” from the top-right scroll menu, and add “<path to PALib>\include\nds” and “<path to PALib>\libnds\include” (without the quotes, anche replace <path to PALib> with the folder where you installed the PALib). Now by pressing Ctrl+Space VC++ will auto-complete for you PALib functions and classnames!
If you are having problems with compiling after following these steps, try reseting your computer.
This step is optional, but I highly recommend it. We are going to setup a NDS emulator as an External Tool, so you can test your project quickly. Click on “Tools”, “External Tools”. Then click on “Add” to create a new External Tool. You can create an External Tool for each emulator you use, but here I show you how to create one for NDeSmuME, the one I use.
Type the emulator name in the “Title” field, then the full path to the emulator EXE file in the “Command” field. In the “Arguments” field you can type “$(TargetDir)\$(TargetName).nds” (without the quotes), and in “Initial Directory” type “$(TargetDir)”. This way you’re passing the .nds file you just built as an argument to the emulator, so it will start automatically.
If you use an emulator such as No$GBA, you must change the “.nds” to “.ds.gba” without the quotes in the Arguments field.
You can even configure a keyboard shortcut (inside “Tools”, “Options”, “Environment”, “Keyboard”), so you can test you app quickly. To map a key to your emulator, select the command “Tools.ExternalCommand[x]” from the list, where [x] is the order of your tool in the list. For example, my emulator is the third tool in the list, so its command is “Tools.ExternalCommand3”. My shortcut is “Shift+F10”, so when I change something in my code I just press “F7” to build and “Shift+F10” to test. Easy, huh?
You can configure a script to copy the file to your card as an External Tool, so it’s easier to test you application in your NDS. To set up that script you follow the above to make a new external tool. Then put “C:\WINDOWS\system32\xcopy.exe” in the command box (this is for xp might be diffrent in vista ) then put “$(ProjectDir)\Release\$(TargetName).nds X:\ /y” ( were x is the letter of the drive ) in the Arguments box and finally “$(TargetDir)” in the initial directory box.
That’s it. Now you have a fully working IDE to develop your NDS games and applications. Obviously you can’t debug your project using Visual C++ debugging environment (altough it would be great) but everything else should work flawlessly.
Update: I was getting a bug with the latest PALib in VCExpress, here is the fix: http://forum.palib.info/index.php?topic=4200.0
Original tutorial by KerneL, revised by ObsidianX :)
Alright, this is a nice step-by-step method for getting PAlib setup and compiling under Linux. I’ve got Ubuntu Linux running, but its pretty generic for the most part so just fix the distro-specific stuff yourself ;)
For Apple MacOSX users, the majority of this howto will work for you too. The only difference being your ‘make’ tool installation. For that you’ll want XCode.
Script By Loumam, posted here by LynkW. Go here: http://ubuntuforums.org/showthread.php?t=750050
Any Linux distro, and the know-how to use it without someone holding your hand.
The latest PAlib (as of this revision) in ZIP form:
devkitARM release 21 for Linux: (use Release 21, 23b is not compatible with PAlib 080823)
libnds 20071023
dswifi 0.3.4
libfat-nds 20070127
First of all, we must organize this mess. Create a new directory named “devkitpro” and make sure you have read/write/execution rights on it. This guide will assume that this folder is in your home directory, but it doesn’t have to be. Extract everything in the PAlib, devkitARM, and libnds archives to the devkitpro directory. Then extract dswifi and libfat-nds into the libnds folder.
Now, you should have something close to the following tree view:
/
|--home
|--<login>
|--devkitPro
|-devkitARM
|--libnds
|-dswifi
|-libfat-nds
|-PAlib
The installation of PAlib requires three environment variables. The best way to do this is to open the “~/.bashrc” file (if you use something other than bash then use the appropriate rc file). Open your favorite text editor and add these three lines:
export DEVKITPRO=/home/yourUsername/devkitPro #this will need to change if your devkitPro folder is elsewhere. Also, replace "yourUsername" with your actual username. export DEVKITARM=$DEVKITPRO/devkitARM export PAPATH=$DEVKITPRO/PAlib/lib
Feel free to adapt these lines according to your own tree view. Apply the changes with this command (only gotta do this once):
$ source ~/.bashrc
Check if everything went fine with the ‘env’ command (it lists every system variable). The following commands will help you to find the new variables:
$ env | grep DEVKITPRO $ env | grep DEVKITARM $ env | grep PAPATH
Note that if you run any of these and just get another $ prompt then the variable wasn’t created. If this is the case go back and check your .bashrc file to check spelling. Also know that you won’t see $HOME in the print out of ‘env’ but your actual home directory path. Example:
$ env | grep DEVKITPRO DEVKITPRO=/home/<login>/devkitpro $
Right, you need to know if you can actually use PAlib. In order to do so, open up a new terminal. (get away from that mouse!) You will need to compile in peace so check this: type in “make”, here, right away. If it returns you something like:
bash: make : unknown command
Then you’ve got a problem. However, if it returns anything else, congratulations, you are good to go! If you get this error, just open your favorite package manager (synaptic, aptitude or use apt-get...) and search for the package named “make”. (If you’re not on Ubuntu find the package that relates to your distro) Install it, the manager will take care of any dependencies. Now your terminal must return:
$ make make: *** Pas de cibles spécifiées et aucun makefile n'a été trouvé. Arrêt.
Or for an English OS:
$ make make: *** No targets specified and no makefile found. Stop.
We will now test our brand new installation. Go in the /PAlib/examples/Text/HelloWorld directory, for a good example to test first. Once you are there, just type:
$ make
If the compilation ends on:
Nintendo DS rom tool 1.30 - Jul 24 2006 06:34:31 by Rafael Vuijk (aka DarkFader)built ... Keyboard.ds.gba dsbuild 1.21 - Jul 24 2006 using default loader
then the job is done successfully. You have a fully functional PAlib! Congratulations!
If you get any weird errors check the forums to see if it’s already been encountered and fixed. Otherwise if you get something like the following:
$ make
main.c
In file included from /home/ryan/devkitPro/PAlib/include/nds/arm9/PA_Sound.h:15,
from /home/ryan/devkitPro/PAlib/include/nds/PA9.h:37,
from /home/ryan/devkitPro/PAlibExamples/Input/Keyboard/KeyboardCustom/source/main.c:2:
/home/ryan/devkitPro/PAlib/include/nds/arm9/PA_FS.h: In function 'PA_FSInit':
/home/ryan/devkitPro/PAlib/include/nds/arm9/PA_FS.h:66: error: 'REG_EXMEMCNT' undeclared (first use in this function)
/home/ryan/devkitPro/PAlib/include/nds/arm9/PA_FS.h:66: error: (Each undeclared identifier is reported only once
/home/ryan/devkitPro/PAlib/include/nds/arm9/PA_FS.h:66: error: for each function it appears in.)
In file included from /home/ryan/devkitPro/PAlib/include/nds/PA9.h:42,
from /home/ryan/devkitPro/PAlibExamples/Input/Keyboard/KeyboardCustom/source/main.c:2:
/home/ryan/devkitPro/PAlib/include/nds/arm9/PA_Motion.h: In function 'PA_MotionInit':
/home/ryan/devkitPro/PAlib/include/nds/arm9/PA_Motion.h:23: warning: implicit declaration of function 'motion_init'
make[1]: *** [main.o] Error 1
make: *** [build] Error 2
...then you somehow managed to screw up your libnds package and should start over from the unpacking process, taking extra care not to mess up anything.
DeSmuMe is an open source emulator and have a linux version which is included in the PAlib_080823_Archive.zip you downloaded already.
To compile it, let’s just the same like previous in the extracted folder :
$ ./configure $ make $ sudo make install
You can also use the Dualis or NO$GBA windows executables with Wine. Install Wine using your package manager and then run the desired emulator through Wine.
$ wine Dualis.exe etc...
You can use PAGfx in Linux (yes, yes, it IS an .exe that you can run in Linux) provided you have Mono installed. Mono is a .NET runtime and is most likely in your package manager. Go on take a look.... You will also need to compile the Linux version of the tool since the binary PAGfx provided with PAlib is coded for the Microsoft.NET and includes code that won’t run on Mono. You can find some binaries on the PAlib forums if you don’t want to go through the trouble of compiling it yourself but I think you’ll find it’s quite easy to do ;) This is an easy process, so don’t worry. All you need to do is install the Mono-GMCS compiler which, in Ubuntu, is as easy as typing:
$ sudo apt-get install mono-gmcs
After this navigate your way to the /tools/pagfx-linux/ directory in your PAPATH and type the following commands:
$ ./configure $ make
Now, if you’d like to be able to run PAGfx.exe anywhere you can also run:
$ make install
but that’s a matter of preference. If you don’t want it globally accessible you can just copy the EXE out of the archive in /PAGfx/PAGfx/bin/Release. You’ll find that it’s already set to executable and you can run it right then and there. If this doesn’t work you can always prefix it with ‘mono ‘:
$ ./PAGfx.exe or... $ mono PAGfx.exe
The EFS_Lib archive in “Other Libs” of the PAlib archive you downloaded comes with a Linux version of the EFS builder.
Alright we did all the work of setting it up for you, now go make us some games, damnit!
Mac section added 12/19/2006 by http://v8media.com, using Mac OS X 10.4.8
Any recent machine will come with the Developer Tools on the installer discs, or sometimes as a separate disc. If you just bought your machine, install off the disc.
If you didn’t just buy your computer, it’s best to look to Apple’s web site to get the most recent developer tools. The place to go for this is: http://developer.apple.com/tools/. It involves registration, but no money. Look around while you are in there, as there are some useful tools for all sorts of things you might do when scripting, programming, or even creating video on the Mac.
Once you have this installed you should have a folder at the root of your hard drive called “Developer”. You will also have many command line tools added. Most importantly, “make”.
There seem to be many ways to do this, and it seems to depend partly on which “shell” you have installed or selected I use the Mac OS X default for 10.4, which is bash. To find out which shell you use, open the Terminal program (from Applications/Utilities) and then select the “Terminal” menu item and select “Window Settings”. Make sure the top drop-down item “Shell” is selected. In that screen, you should see the 2nd line saying Shell: . If it’s bash, here’s how to set your “environment paths”.
If you are using something other than bash, you either know what you are doing, or will need to find a tutorial to set up your environent paths for your shell.
Environment Paths are just paths in your operating system that you or a program define to let yourself or a program do something more easily. For example, say that everyday you have to log in to another machine using the terminal using ssh to check a university email. The first step would be to log in to the server, probably using a program called ssh. Here’s what a command for that might look like: “ssh -i firstname.lastname@server.university.com”. If you are doing this from your own machine, you can simplify this by making what is called an alias. your alias for this example might simply be “unimail” or something of the sort. Far easier to remember. We do this in a hidden file in your home directory called .bash_profile.
1) To create the file, or open the file if it already exists, open a new terminal window. 2) type in (without the quotes) “pico ~/.bash_profile”. Now you should see a blank screen and some text a the bottom starting with: Get Help, Exit, WriteOut . . . You are in a program called Pico. All control is via the keyboard, your mouse won’t help you here. 3) copy and paste these next two lines:
export DEVKITARM=/opt/local/devkitPro/devkitARM export DEVKITPRO=/opt/local/devkitPro export PAPATH=/opt/local/devkitPro/PAlib
4) Hold the “control” key, and then press the “x” key, this sends the Exit command to the program. It asks if you want to save, so press the “y” button. It then comes up with a screen asking what the name of the document should be, we gave it a name when we made the command to open Pico, so just hit the “return” key.
5) Either close this terminal window or type source ~/.bash_profile so that your changes will take effect in it.
6) There is no step 6.
Disclaimer: I have not gotten a dswifi app to compile yet, I’m filling in what I know how to do so that someone who knows this part well will have an easy time of updating this with the correct information. Thanks ahead of time to whoever fills this information in!
Download the current version of devkitARM (It was at 21 as of 11/25/2007). This includes devkitARM and libnds. Here’s the link: http://sourceforge.net/project/showfiles.php?group_id=114505&package_id=124207&release_id=549080. This is processor specfic. If you have an Apple PPC machine, download the osx version, if you have an Intel machine, download the Intel version. Both contain double-clickable package files. Go ahead and install these.
There are also examples listed “nds examples 20060817”. Download those, or a newer version if one exists. Now we start getting to issues. It seems like the libs we just installed aren’t fully aware of the capabilities of the OS, and don’t seem to be able to deal with spaces in the names of files. As long as you put the example files and any others that you are working on directly into the “Users/MyUserName/Documents” or in a folder with no spaces and with project names with no spaces, you will have no issues. I found it easier to put the stuff in a folder in the root of my hard drive. So I have “ianDS”, and “libnds_examples_20060817” as two folders in the root of my main drive.
After you place these files, we can test out some compiling. Here’s a step-by-step easy way to do this.
1) Have one Terminal window open, and one Finder window where you can see the example file you want to try compiling. I’m using this file: /libnds_examples_20060817/Graphics/2D/256_color_bmp/. What you want to be able to see is the draggable folder name of the project.
2) Type “cd " into the terminal. That’s a space after c, and d. 3) Drag the folder of the project you want to work on to the Terminal and let it go. It copied the whole path in there so you don’t have to do it your self or find your way there using shell commands. 4) type “make”
You should see something like this in your terminal window:
The important part there is where it says “built” near the bottom. As opposed to “Error”.
You should also see that your folder filled up a bit so it looks like this (if you are using column mode):
Woohoo! If you see this, you’ve just compiled multiple copies of a program. These can run on your flashed Nintendo DS or in emulators. For instructions on specific cards, look here, which is back up the page in the Windows section Putting the homebrew on the DS. If you are going to be doing much coding, I suggest using an emulator most of the time as this will be far faster than swapping cards, moving files, and unplugging and plugging cables every time you compile. Maybe just toss it onto actual hardware when you get something that you wonder how it looks for real or is complex enough that it may work differently than on an emulator.
One other thing you can do here while you still have the Terminal window open: type “make clean” and hit return. This should get rid of the files that were created during your “make” expedition. This can help you make sure that any errors you might get were not from extra files in your project.
Next up is PAlib. http://palib.info/forum/modules/PDdownloads/. Take the latest stable release, in Zip format. Unzip it, and move the PAlib folder into /opt/local/devkitPRO alongside the other folders there. You may also need to replace /opt/local/devkitPRO/libnds with the version included with PAlib, but I would reccommend not doing this unless you get errors building PAlib examples ever. The rest of the folders and files in PAlib are examples and documentation, so they can go wherever you please.
Note: If you are having problems with testing, check that PA_Makefile is in the PALib directory (it may be in the PALib/lib directory). If it isn’t, move all the files from PALib/lib to PALib.
To test that everything has been installed properly, fire up Terminal.app and cd to the location where you installed PAlibExamples. Next type the following commands:
cd Demos/Bunny make clean make
With luck, you should see something like this after the last command:
arm-eabi-g++ -g -mthumb-interwork -mno-fpu -L/usr/local/devkitPRO/PAlib/lib -specs=ds_arm9.specs main.o -L/usr/local/devkitPRO/PAlib/lib -lpa9 -L/usr/local/devkitPRO/libnds/lib -lfat -lnds9 -ldswifi9 -o build.elf Nintendo DS rom tool 1.33 - Jan 31 2007 19:37:59 by Rafael Vuijk, Dave Murphy, Alexei Karpenko built ... Bunny.ds.gba dsbuild 1.21 - Jan 31 2007 using default loader
A piece of software that can be quite helpful on newer Apple Intel machines is WINE. WINE stands for WINE Is Not an Emulator. Since the newer Apple machines already have Intel chips, you don’t need an emulator to be able to run Windows programs, what you need is an environment to run those programs. Download from here: http://darwine.opendarwin.org/download.php. That’s an easy download and install, but you do need to have X11 installed, which you can find here: http://www.apple.com/downloads/macosx/apple/x11formacosx.html.
Some programs will need a Windows DLL file in order to run. If this is the case, you’ve got to find the DLL, maybe copy it from a Windows machine you have access to. Once you have it, just put it in the same folder with the program that you are trying to run. Start off simple and try with the sample programs that come with Darwine before you try something else.
Since the only programs you really need to run on the Windows side of things will most likely be the graphics conversion programs, being able to open them in a window instead of in a whole operating system is ideal. The program that comes with PAlib seems to work ok. You should find it here on your computer after installing PAlib: “/opt/local/devkitPro/PAlib/Tools/PAGfx/PAGC Frontend.exe”.
If you are running a less recent Apple machine with some sort of PPC chip (G3-G5) what you will want is a copy of QEMU. The Mac OS X version is called just “Q”. You can find this here: http://www.kju-app.org/kju/. If you are familiar with Virtual PC, you will find this to be pretty similar. Including that you will need a copy of Windows 98, 2000, or XP in order to use it.
Unfortunately, I have yet to get Darwine to run PAGfx, so I am currently using Parallels, which is a paid product. But worth not having to boot into Windows if all you are using is some tiny utility program. http://www.parallels.com/en/products/workstation/mac/. If you get Darwine to run some of these utilities, please post your success.
Another piece of useful software is GraphicConverter from LemkeSoft http://www.lemkesoft.com/. You can apparently use this to convert images to the format for the GBA and DS.
Here is how to do the preliminary steps: Make sure you have the most recent version of GraphicConverter. If you don’t it might not work. After you check (or download it), open your file in GraphicConverter. Simply save the file as a “Byte-Array-Header” file.
After you do this, you can take your “.h” file and put it into a piece of software called hConvert http://www.patatersoft.info/hconvert.html. hConvert will take your .h file and turn it into a .bin file.
See the site for more info: http://www.patatersoft.info/manual.html
With the release of PAGfx-Linux, MacOSX users now have the oportunity to use the PAGfx command line version without a problem. All you have to do is to install ‘mono’ (http://www.mono-project.com/Main_Page), automake 1.10 and autoconf. Autoconf can be installed using apt-get tool (very useful, install it if you haven’t yet), but automake has to be installed manually (apt-get only finds up to 1.9 version), however the instructions can be found easily googleing a bit. Then follow the instructions on the README file in PAGfx-Linux folder to install PAGfx. Once everything is installed you only have to put all your graphics on one folder, create the PAGfx.ini file (see sprites tutorial) and go to that folder on the terminal and type ‘pagfx’.
You will be glad to see that Apple’s Airport cards can be used to talk directly with the DS. Superb instructions here: http://www.macosxhints.com/article.php?story=20051119155606277.
This introduction will cover the basic homebrew development toolchain as well as some of the most commonly used add-on libraries. It also includes a short discussion of available emulators and hardware (flash cards) for testing your projects.
Thanks to the excellent work of many coders in the DS development community, the Nintendo DS is certainly one of the easiest video game systems for homebrew developers to jump into. With the free development tools these coders have made available, even beginning coders can produce high quality games in a surprisingly short period of time. But remember, even with the best tools available (and I consider devkitARM and PAlib to be among the best for any system), producing a high qulaity game requires a lot of persistence and attention to detail.
The foundation that makes makes C/C++ development possible on the DS is the free devkitARM toolchain from devkitPro, including the libnds library. DevkitARM provides basic C libraries and a compiler targetted to the DS’s ARM architecture while libnds includes many functions and macros for accessing the DS’s specific hardware features.
PAlib adds to the devkitARM toolchain by giving DS developers a higher level entry point to the hardware, allowing them to focus on producing code rather than deciphering the complexities of the DS’s hardware layout. PAlib is primarily intended to aide the development of original games on the DS. The bulk of its features are designed to make the end user interface better and easier to program. Graphics, sound (thanks to ASlib, which is incuded as part of PAlib) and user input are PAlib’s strong points.
In addition to devkitARM, libnds and PAlib, many other libraries are available to make various aspects of homebrew DS development easier.
There are currently only 5 emulators. I highly recommend using exclusively No$GBA, it’s the most accurate one.
Ensata is another emulator out there. It’s a crack/leak of an internal Nintendo emulator included with the official SDK. Due to the lack of legality, we don’t use this.
What you’ll need first is something to actually hold all the homebrew programs that you have created on the DS, this is done by purchasing and using a “flash cart”, most flash carts out there are for the GBA but now have been made to work for the DS. You can purchase many types and brands of flash carts, some with internal memory, some without. I’ll review the most popular ones, although remember that you may not want to purchase these mentioned, or even from the store which I’ll link to, but you will have to buy one if you ever intend to run your homebrew on an actual Nintendo DS. You’ll also need a PassMe of some sort (if you get a slot 2 card), which I’ll get to later. (Reader sidenote: Slot 1 cards are much cheaper and much easier to use then slot 2 cards, and don’t require the use of a PassMe with the downfall that they can’t directly use GBA games, but can with a relatively cheap expansion slot 2 card like the EZ-Flash 3in1)
Now, no matter what you do, you will always need to use one of these next methods to run your DS homebrew programs. It comes in just five variations, although the first three seem to be the most widely accepted.
It would be best to keep your flash cart and passme-device from the same maker to ensure compatibility so combine as follows: EFA Linker and EZ Flash with PassMe2, SuperCard with SuperPass/SuperKey, and M3 or G6 with PassKey2/PassCard 3.
as soon as you compile your program/PAlibExample/homebrew, “magically” three files appears in your program root directory:
just pick the file you need and put on your flashcart! well done!
Using the SuperCard with SuperPass
If you are using the SuperCard with a SuperPass (as shown in the picture below), the homebrew application you’ve created should be easy enough to be selected from the menu, as soon as you switch your DS on, a menu should appear on the top screen.
Using the SuperCard with a flashed DS
If you have flashed the DS Bios with the FlashMe method, after you have inserted the SuperCard into the slot, as soon as the DS is switched on, keep pressed the buttons A + B + X + Y, the SuperCard menu should now show up, select the file named “mygame.sc.nds” (remeber?) and launch it pressing A, if everything went well, your program should come up on the DS. Well Done.
次 → 2日目 - C言語入門
— Translated by kuy 04/11/2008 03:11