How to program on ds




















Connect and share knowledge within a single location that is structured and easy to search. I was reading this answer previously and it got me interested in purchasing a Nintendo DS Lite for learning to program embedded devices. Before I go out and splurge on a DS I had a few questions:. Are there any restrictions on what you can program?

The post I indicated earlier seemed to say there weren't, but clarification would be nice. Would I be better off buying an arduino or similar and going that route? I like the DS because it already has a lot of hardware built in. Thanks for your time, If you have a DS and program on it, I'd love you hear your opinion, or alternatively if you have a better idea, I'd like to hear it too.

No, there really isn't much of a limitation beyond that of the hardware, and even that can be overcome with enough effort. Quake has been ported to DS, for example, and particle games that utilize both processors have been made. There has also been discussion on how to make higher quality 3D scenes using a double pass renderer. I would say that the DS is an excellent route to embedded systems development; there is a large and active community that is willing to answer questions and give support, and there is so much hardware built straight into the thing.

It saves you the time of building a system to test on. The CycloDS Evolution is a good card and is fairly common, so it shouldn't be difficult - if necessary at all - to make your homebrew compatable with other cards. However, be aware that other popular choices are the M3 line and the R4 line, which are pretty much the same thing.

I have a TTDS, and it works well, but not out of the box. I would reccommend the other three mentioned. I've done a little programming on the DS Lite about 1 year ago. The major hardware limitation that I had was working with the WiFi hardware. I found that DS-DS communication was not possible with the homebrew libraries at the time.

I am not sure if that has changed. I also found that you could not form an Ad-Hoc connection to another device. I had to connect to an At the time this was the only option.

There are now DS slot only solutions such as the R4. I will say, however, that the reason for the degrees is due to libnds's built-in look up tables for the sin and cos functions. Having only entries in your lookup table would be a waste of space when it takes just as many bits to index into a entry table as it does a entry one. More entries allow finer accuracy.

In order for the Nintendo DS to know how to rotate our sprites, we have to convert the internally stored radian angle value to a value within the degree system. This is an easy conversion. The first step is to convert to a degree system, as you must have learned in junior high school. The part is half the number of degrees in a circle. Lastly, just return that value as an integer.

The hardware does not have any floating point, so when rotating our sprites, we use a fixed point value disguised as an ordinary integer.

Then, we make a function to return a converted angle value, for whenever we need it. We now need to create an instance of the ship in our main function. Creating an instance of a class, known as an object, is quite simple, as you can see below. We just have to create the Ship object and then assign a SpriteEntry to it. We should also do something nifty with our new class so that we can verify that what we wrote is working.

Let's make the ship move around on its own by telling the ship to trust ten times. The previous code isn't very exciting, since we never update the OAM more than once. We need to begin the creation of what is referred to as the game loop. We won't be fully implementing it in this chapter, since a major component of it will be missing until we discover input on the Nintendo DS. The game loop has at least three major components. The first thing any game loop should do is to collect input from the outside world.

We won't be doing that in this chapter, however. The next component of the game loop is updating the game state. Based on inputs the game received in the previous frame to the one we'll render next and the passing of time, the game state will change if anything interesting is happening. The final component of the game loop is the rendering component.

In our case, we have to update the OAM to let it know of the changes that occured in the game state and that it needs to reflect those changes. Now that we know what a game loop is, it's time for us to start creating one to run our program.

The first thing we want to happen in our game loop is for the game state to be updated. This is because we don't have any input to collect yet. We tell our ship to move at it's current velocity. Then we update the sprite attributes with new information about our ship, as some properties of the ship have now changed i. Finally, we call a function that will make sure our program does not exceed 60fps speed of the graphics on the Nintendo DS by waiting for vblank, and then we update the OAM, telling it that we changed some attributes on the sprites and it needs to handle that.

The OAM really shines through here. The all powerful Nintendo DS hardware, an incredible masterpiece, will rotate and move our ship with very little effort on our part. In hindsight, all we have done is flip a few bits in a few registers in a structured manner, and our ship comes to life. Verify that you are including all the files you need to include now, before compiling. Everything should compile for you fine at this point if you wish to play around with your new class.

However, in the next chapter we will cover how to get Nintendo DS input to affect the Ship. Be ready for it, we're going to have some major fun. The Nintendo DS has many different user input systems, including buttons, touch screen, and a microphone. Most video game systems only have buttons and an analog stick or two. While the Nintendo DS does not have an analog stick, it does have an amazing touch screen which has millions of different creative uses.

We will only cover the touch screen and buttons, though. Instead of having to AND registers with cryptic masks to discover which keys we are pressing, we simply call scanKeys , then check one of three input functions, keysDown , keysHeld , or keysUp.

In order to see which keys have been recently pressed, use keysDown. To see which keys are currently held, use keysHeld. To see which keys have just been released, use keysUp.

How they are set up is explained in Table 8. The touch screen a big part of what makes the Nintendo DS awesome. The libnds API for using it is cake easy too. We'll be ready for Utada Hikaru in no time. Whenever you want to read the current touch location, simply call the function touchRead.

This function assigns values to a struct that contains the x and y coordinate of the touch. You use it like so. You may see code that uses something called the IPC to interact with the touch screen.

Use of the IPC struct is deprecated. This means that you shouldn't use it and should not depend on it being there in the future. The method we use to read values from the touch screen does not use the IPC struct and is safe for future use.

Now that we know a bit about how input is laid out on the Nintendo DS, let's write a function in our main. We'll call it updateInput. We'll use this function as the first thing we call in our complete game loop.

This function will be part of our game state updating game loop component. It will react to outside input and modify the game state accordingly. As such, it will have to know about and be able to modify the game state.

We'll pass the game state to it as function parameters. Let's call the function handleInput. First, we want the ship to accelerate when we press up. To do this, we detect when the Nintendo DS has the up key on the D-pad held which included the initial down press and accelerate the ship if so. The up key will constantly read as held, so long as it is held.

Reading the input does not affect the keys register. We'll do similar things for each of the other keys. See if you can tell what each key does from the code listing below. As you've noticed, having that Ship class made input handling extremely easy. Our keys will directly affect various properties of the ship as we press them.

This is really amazing, but the true miracle is yet to come. As for the moon, since we didn't make one class for it, the code came together a little more messily.

We also had to pass two parameters to the handleInput function to represent the moon portion of the game state instead of one. If we had wanted to be more clean, we could have even produced a game state struct that contained all the game state and all operations on it in one place. Let's check back in on our main function now. We need to make some adjustments to our game loop since we've now added the ability to collect input and to react to input.

The first thing we now want to happen in our game loop is for the key registers and read touch screen coordinates to get updated. We make a call to updateInput and it all happens for us.

Next, we handle the input we just received by calling our recently created handleInput function, passing in our game state so that it can change it for us. Everything else is as before. Again, we should double check that we have all the proper includes before compiling. Now we can control our ship with the D-Pad. What fun! The game should now appear as in Figure 8. Now if only we had some aliens to kill…. Sounds are essential in any game. Our little project should be no exception. Sounds bring life to various elements in the game, such as space ships, weapon systems, rain, sword clashing, car engines, and so forth.

Many games don't need music. For instance, a game with the programmer's or game designer's favorite song may annoy many players who have different tastes in music. Instead, give the player the option to listen to their own music, on their own audio equipment. Not to mention, music can be costly in data size. Sound effects on the other hand, are quite useful. A word of warning, however, a game with bad sounds scratchy, annoying, too repetitive, etc.

Take care when engineering sounds for your game. The Nintendo DS has amazing sound hardware. We will only be able to scratch the surface of it, and even still, we won't leave any scratch marks.

The Nintendo DS has 16 channels to play sounds, numbered 0 through Channels are special channels. We will only be experimenting with PCM sounds. To play our sounds, we will use the unbelievebly impressive homebrew audtio library, maxmod. The makefile I've included with my manual has a custom rule for creating a soundbank. The rule runs mmutil to create the soundbank. The bin2o rule turns the. All of these header files will be located in the build folder after a build, if you wish to review their contents.

Now it's finally time for some code. All we need to do is initialize the library, let it know where our soundbank is, load the sound from our soundbank, and call a function to play the sound.

It will serve our purposes for now, as a springboard into more advanced forms of sound. Enough with the chatter, here's some code for our main. In summary, we simply set up our sound in the main function, and had the handleInput function play our sound whenever the up key is initially pressed.

We are barely touching what maxmod can do in this case study. I highly recommend you read about it on its homepage , or at least run the maxmod demo featured on said homepage on a real Nintendo DS. You won't be disappointed. This is the final iteration of the Orange Spaceship demo that we will cover in this edition of the manual.

Compile it and enjoy the fruits of your labors. Mmm, tasty. You should hear a nice sound when you press the thrust button. The game output should now look like the screen shots in Figure 9. I hope you've enjoyed reading this manual as much as I've enjoyed writing it.

I hope it has helped you to learn the basics of Nintendo DS programming, and if not, that it has pointed you in the correct direction. I wish you luck in all your future projects and endeavors.

Feel free to contact me mailto:jaeder patatersoft. I'd like to offer special thanks to all those who have taught me these past few years about Nintendo DS programming. I apologize if I've left anyone off the list who has helped me. Special thanks to:. He graduated in December from Brigham Young University.

Introduction to Nintendo DS Programming. Jaeden Amero. Revision History Revision 6. Revision 6. The manual's case study has undergone a significant rewrite and covers more ground than ever before. Revision 5. Manual is now DocBook formatted. Revision 4. Revision 3. Revision 2. What is a passthrough device and how do I use one? How would I choose an old style passthrough? How do I get programs into my Nintendo DS? What is DLDI? So, which Slot-1 devices are good? How do I create programs?

How do I display a background? What is a sprite? How do I use them? Magical Fairies? Displaying the Sprites Compiling 7. What about the sounds? List of Figures 2. The PassMe inserted into the DS card slot 3.

The Raster Display 5. The program should look like this when run. Output with both backgrounds and a sprite. Flying around in the Orange Shuttle. Flying around in the Orange Shuttle, with sound! List of Tables 2. Mode 5 Information 5. Table of Ship properties and functionality.

The Main Issue. The Solution. How to Use this Manual. Chapter 1. Background Information. Is Homebrew Legal? Chapter 2. Purpose of the Passthrough. How a PassMe Works. History of the Passthrough. About the NoPass. About Slot-1 Devices. How do I get a Passthrough. Which Passthrough Should I Buy? Procedure 2. Join any room you wish. PassMe 2 Buying Tips. How do I use my Passthrough. The PassMe inserted into the DS card slot.

What to do with your Passthrough. Chapter 3. The Methods. Which Slot-1 Device should I buy? M3 Real. Cyclo DS Evolution. Where do I get one of these Slot-1 devices? The Slot-2 Device of Choice.

Running Multiple Software Titles. Chapter 4. Python Pillow. Python Turtle. Verbal Ability. Interview Questions. Company Questions. Artificial Intelligence. Cloud Computing. Data Science. Angular 7. Machine Learning. Data Structures.

Operating System. Computer Network. Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology. Cyber Security. C Programming. Tips and Warnings. Things You'll Need.

Related Articles. Author Info Last Updated: June 10, Download Microsoft. NET Framework 3. Install the program. Follow the automated steps, it is really simple. You can choose if you want to add a shortcut or whatnot. See the games page - the section titled 'How to Play'. For reference, devkitPro is the development tool chain with the DS-specific devkitARM, PAlib is a simple add-on library and DS Game Maker is an interface for these so you can make games without having to learn programming.

These are only rough steps. The Manual covers everything in full detail. No, but if you have a flash card, like an R4 cart, then you can copy your game to it and play it. Yes No. Not Helpful 5 Helpful



0コメント

  • 1000 / 1000