-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|376|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Article Home -> Coding Basics


 
Jayenkai
Created : 15 October 2007
Edited : 19 October 2009
System : PSP Vita
Language : Delphi/Pascal

Half an Hour, DS Jumpstart

Kick off your DS homebrew with this jumpstart tutorial.

Jayenkai's Half an Hour DS Jumpstart Guide.

This guide assumes you can code, and that you're aware of how to repeat simple instructions!
It also assumes you know how to second guess those instructions, and that you can pretty much figure things out as you go along, based upon common sense, and your previous coding knowledge.

In essence, this is a really basic set of instructions, designed to get you up and running really really quickly.

Step 1 : 00:00 (Please note that all times are approximate! I didn't time myself!)
First up, three links.
DevKitPro, This DevKitArm and This PALib.

For the record, Spinal prefers DevKitArm r21!

Download all three!


First install the main DevKitPro package. You needn't change any of the options, unless you don't need PSP (and others) support, but do be aware that PALib is designed for NDS development ONLY, so if you do decide to make use of the PSP DevKit, you'll have to learn the slightly more annoying way of doing it!

Next install the DevKitArm package.
This is an older version of DevKitArm, but is most suited to run with this version of PALib.

Last but not least, install the PALib package linked above.

PALib is basically a nice neat gfx library, and it helps avoid having to do all that setup gubbins that us Blitzers hate so much!

The version above is compatible with the DevKitArm you downloaded previously.

I should point out that newer versions of DevKitArm and PALib are available, but finding two that work together nicely is a bit hit and miss.
Use the above as your default setup, and only play around with newer versions if you really feel the need.

Step 2 : 00:10
No$GBA
This is the best of the emulators. Sure, it won't let you do File Access just yet, but it'll do pretty much everything else..
And do it well at that!
Hit F3 at any time for a nice little "Yor game es borked!" or "Yor game aint borked! Yew code goodlie!" alert. It'll vaguely help you debug your game.
If you need more debug info than that, you can fork over for the full priced debug version of No$GBA. But I haven't needed it so far, so don't rush into it


Step 3 : 00:11
Your Coding Space
Make a nice neat area on your HD, designated to DS Coding. (or, whatever! I don't know how you organise things!) Note, wherever you choose to put it, you can't have ANY spaces within the whole of the filename.
I chose c:\dsdev\
Next grab C:\devkitpro\PAlibExamples\Text\Normal\HelloWorld
copy and paste the directory to c:\dsdev\HelloWorld
Head inside, and double click on Template.pnproj
If Programmers Notepad doesn't open at this point, open it up manually (it's inside the devkit folder) and let it associate itself with the pnproj files.

Step 4 : 00:12
A quicky test
Once you opened up the pnproj file, there should be a Projects list on the left of Programmers Notepad, and inside the Source folder there's a Main.c
Open that up.
Alt+2 to clean the folder.
Alt+1 to build the project.
Flip back to the folder and you'll now see 3 new HelloWorld files at the bottom.
For reference, they are as follows.
HelloWorld.ds.gba - This works in No$GBA
HelloWorld.nds - This works on my cart, and seems to work on most.
HelloWorld.sc.nds - This works on SuperCard carts.
When releasing your games it's probably best to include all 3, just to be on the safe side, but for the most part the .nds one will do.

Double click the .ds.gba game, and if need be associate it with No$GBA.
Everything should've worked by this point, and you should now see 2 black screens. One with "Hello World !" and the other without!
Escape to quit No$GBA

If it hasn't worked, kick the PC and scream a bit.

Step 5 : 00:15
If you kicked your PC, do not attempt any steps beyond this point

The hello world example runs like so.
Include PALib, Main Loop, Initiate PALib, Initiate VBL's, Initiate Font on screen 1 (top) and buffer 2 (there's 4 buffers per screen, 0-3), Print, Loop till quit, Return.

The Loop till quit is a bit of a dodgy thing, as you probably won't ever quit.. some DS carts don't let you return to their menus.
But, once you've got coding, it's inside this Loop till Quit that most of your base coding will happen.
Other than that, you're going to be using a whole load of functions.

Step 6 : 00:20
Sprites
In the explorer window, head into the Sprites directory, and make a gfx directory.
Inside, create a small .gif image. Anything you want.
Sizes should be 8x8,16x16,32x32,64x64 or 8x16,32x64, etc..
If you want to add extra frames, stick them all below one another, like you would a Blitz AnimImage. Note that it doesn't like them lined up horizontally!
Save your gif with <256 colors (as in NOT 256.. It doesn't seem to like 256! It's happy with 255!)

I grabbed a picture of Frogger, and saved it as frog.gif

Next copy C:\devkitpro\PAlib\Tools\PAGfx\PAGfx.exe and C:\devkitpro\PAlib\Tools\PAGfx\PAGfx.ini into the gfx folder of your game.
edit the .ini file so it looks like so.


Save, exit, and run the .exe
This will convert the .gif image to a nicely formatted array, leaving behind a big pile of crap! Ignore it, and go back to your main.c file..


Add that near the PALib include, and then just before the Loop-till-quit, we want to load our frog sprite into memory.


Note, since we're using the system's Sprite handling, we don't need to redraw the image every frame like we do in Blitz.
Just set it's position, frame and other bits and pieces, and it'll stay there until we change it. (Which in some cases can be really annoying when you forget to move them! )

Run, Test, and you should now have a frog on the bottom screen.

Step 7 : 00:25
Input/Movement
This extension of the code adds basic movement to the frog.
Cursor / Face Buttons for direction, and Stylus tapping to change his anim to the 2nd frame.
If you don't already have 2 frames for your frog, go and add one now, and don't forget to rerun PAGfx to redefine the graphic arrays.



Really basic stuff, but it should be enough to get you going. (It's enough to code a JNKPlat with )

Now, head over to PALib's own tutorials, and you can get to grips with the whole complex system of DS Developing!

Good luck!

 

Comments


Tuesday, 16 October 2007, 08:55
rockford
Many thanks. I'll have a play with this later
Wednesday, 31 October 2007, 05:50
spinal
for quickness and cheapness the datel Games'n'music Is quite good (I've heard) and you get a microsd card with it.
Thursday, 03 January 2008, 14:18
Yo! Wazzup?
I don't have the 3 files after the build, I get the following:


|edit| Is now a good time to kick my pc and scream? |edit|
Thursday, 03 January 2008, 14:56
Jayenkai
I know, I've gotta rewrite a couple of things.. The latest PALib and DevKit are bizarely incompatible.

Gimme a few mins, and I'll get you a couple of extra downloads.
Thursday, 03 January 2008, 15:22
Jayenkai
OK, I've updated step one, so future peeps can get the thing working first time!
Yo!, to get things working, you'll want to do the following.

First download This DevKitArm, and install it over the top of what you've got. Should install just fine.
Next, head into c:\devkitpro and remove all the PALib based folders. (Just to be on the same side)
Then grab This PALib and install that instead.

Basically the issue comes from the fact that both PALib and DevKit are in a state of flux, right now.
It's gotten a lot more difficult to find two compatible versions that play nicely!
So, what I've done is I've grabbed the ones that I'm using, and shoved them up for everyone to use. They do play well together, and even install as they should, as both .. um.. (memory lapse) two other Socoder members have tried to do the same thing in the past couple of days.
Friday, 04 January 2008, 05:59
Yo! Wazzup?
K, when I run the Hello World program, is it supposed to say "This wouldn't work in a real cartridge"?

|edit| Still works, but the dialog pops up first. |edit|
Friday, 04 January 2008, 06:07
Jayenkai
Run the .ds.gba in No$GBA, the popup shouldn't then happen.

No$ is just being honest. Homebrew won't run in a "Real" cartridge.. But it will in a homebrew cart!
Thursday, 07 February 2008, 16:49
jakain
Wait so Agent Smith, you have mac and i do too. but i cant do the .exe files how do you do this?
Monday, 23 August 2010, 20:15
CodersRule
I'm bumping this up quite a bit...
Hey look, I've posted in this before! Funneh.

ANYWAY. I compiled, but only got one file. (the .nds file) I ran it on my homebrew cart, and it just showed two white screens. I have the strangest feeling I did something incorrectly.

Would the devKitPro build itself be causing the problem or is devKitARM the only interference?
Sunday, 05 September 2010, 19:16
CodersRule
Just uninstalled and reinstalled everything, this time trying devkitARM 21. Now it's not outputting any files whatsoever, and


D:
Monday, 06 September 2010, 01:22
Jayenkai
Freshly done from scratch, first time installing on Win7 system.
1. Installed DevKit
2. Removed DevKitArm folder
3. Installed DevKitArm_r20
4. Installed PALib
5. Compiled games.

*shrugs*
Could be an r_21 issue?

Reinstall r_20, then grab this

Clean, then Build it, and see if it compiles.
If it does, um.. it's a bit messy, in fact it's REALLY messy, but it's what I use as a start point each time I start a new DS Project.
.. So, um.. Good luck with that!!!