<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5115724191902352587</id><updated>2011-12-29T23:34:26.125-08:00</updated><category term='tile'/><category term='angle'/><category term='writing file'/><category term='devkitpro'/><category term='irq'/><category term='free'/><category term='compile error'/><category term='jailbreaking'/><category term='registers'/><category term='application'/><category term='NSString'/><category term='sprite'/><category term='array'/><category term='Interfacebuilder'/><category term='iphone'/><category term='download'/><category term='timer'/><category term='sound'/><category term='multiple view'/><category term='NSNumber'/><category term='tiles'/><category term='attributes'/><category term='Objective-C'/><category term='double free'/><category term='makefile'/><category term='iprintf'/><category term='sprites'/><category term='scripts'/><category term='update'/><category term='nds'/><category term='subview'/><category term='sin'/><category term='gfx2gba'/><category term='betatest'/><category term='DSerial Edge'/><category term='pinball'/><category term='atan'/><category term='CGContextShowTextAtPoint'/><category term='provisioning profile'/><category term='links'/><category term='UIScrollView'/><category term='int'/><category term='rotation'/><category term='malloc'/><category term='xcode'/><category term='terminal'/><category term='palette'/><category term='oam'/><category term='emulator'/><category term='reading file'/><category term='homebrew'/><category term='color'/><category term='double background'/><category term='source code'/><category term='triangulation'/><category term='microphone'/><category term='DebuggingAutorelease'/><category term='maxmod'/><category term='release'/><category term='interrupt'/><category term='tuto'/><category term='Entitlements'/><title type='text'>nds - iphone - homebrew</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://nds-homebrew-hslleiden.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-1594262328951400357</id><published>2011-12-29T12:23:00.000-08:00</published><updated>2011-12-29T23:34:26.144-08:00</updated><title type='text'>starting with android</title><content type='html'>After an Iphone and the Appstore, in between a Sony, now an android because of the IOIO microcontroller.&lt;br /&gt;&lt;br /&gt;starting with Eclipse, the first android tutorial:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.higherpass.com/Android/Tutorials/Writing-A-Basic-Android-Application/"&gt;http://www.higherpass.com/Android/Tutorials/Writing-A-Basic-Android-Application/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and more:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.higherpass.com/Android/tutorials/"&gt;http://www.higherpass.com/Android/tutorials/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;but doing buttons and relative layout is not really JAVA....&lt;br /&gt;for JAVA in android this link:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://mobile.tutsplus.com/tutorials/android/java-tutorial/"&gt;http://mobile.tutsplus.com/tutorials/android/java-tutorial/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After that, usually, one wants to bounce a ball:&lt;br /&gt;&lt;a href="http://www3.ntu.edu.sg/home/ehchua/programming/android/Android_2D.html"&gt;http://www3.ntu.edu.sg/home/ehchua/programming/android/Android_2D.html&lt;/a&gt;&lt;br /&gt;using a View with a ball inside, and showing extra possibilities.&lt;br /&gt;After adding touch, all is wrapped up in an OOP fashion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-1594262328951400357?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/1594262328951400357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/1594262328951400357'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2011/12/starting-with-android.html' title='starting with android'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-2947286127243332565</id><published>2010-05-29T23:58:00.000-07:00</published><updated>2010-06-07T22:25:51.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='double free'/><category scheme='http://www.blogger.com/atom/ns#' term='source code'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><title type='text'>Some basic templates for Iphone coding</title><content type='html'>Starting up a simple Iphone app, without much coding...:-)&lt;br /&gt;&lt;br /&gt;Step  0:&lt;br /&gt;a link to a photoshop template:&lt;br /&gt;&lt;a href="http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/"&gt;http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/  &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Step 1:&lt;br /&gt;download the 3GB Xcode with simulator:&lt;br /&gt;&lt;a href="http://developer.apple.com/technology/xcode.html"&gt;http://developer.apple.com/technology/xcode.html  &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Step 2:&lt;br /&gt;A very basic template with 5 backgrounds is  downloadable here:&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/ExampleTemplateView5.zip"&gt;ExampleTemplateView5.zip   &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Step 3:&lt;br /&gt;Unzip the folder and look at the contents:&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/iphonehelp3.jpg" title="iphonehelp3.jpg"&gt;&lt;img src="http://www.contrechoc.com/iphone/iphonehelp3.jpg" alt="iphonehelp3.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and all the possible other steps:-)&lt;br /&gt;&lt;br /&gt;start  with editing the pictures, 320 x 480 pixels, and save the changed  pictures in the folder under the same names,&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;OR&lt;/strong&gt;,  change the names in the folder &lt;strong&gt;AND&lt;/strong&gt; in the code, see  next image:&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/iphonehelp1.jpg" title="iphonehelp1.jpg"&gt;&lt;img src="http://www.contrechoc.com/iphone/iphonehelp1.jpg" alt="iphonehelp1.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can also add images immediately to the xcode. Then these images have to be dragged in the space under the other images in the space at the left side of the xcode window, so under Groups and Files and Resources...see this image:&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/iphonehelp4.jpg" title="iphonehelp4.jpg"&gt;&lt;img src="http://www.contrechoc.com/iphone/iphonehelp4.jpg" alt="iphonehelp4.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After dragging the image in the right place, you get a window asking to add the image to the destination folder: check Copy radiobutton...&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/iphonehelp5.jpg" title="iphonehelp5.jpg"&gt;&lt;img src="http://www.contrechoc.com/iphone/iphonehelp5.jpg" alt="iphonehelp5.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Then get the simulation running by  clicking the green button with the hammer, the BUILD&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/iphonehelp2.jpg" title="iphonehelp2.jpg"&gt;&lt;img src="http://www.contrechoc.com/iphone/iphonehelp2.jpg" alt="iphonehelp2.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When changing the images do a STOP and  then again a BUILD.&lt;br /&gt;Other example with the splash, the middle images  and the finishing page:&lt;br /&gt;&lt;br /&gt;download a template with splash,  (starting screen) some basic backgrounds, (in a slideshow) and a  finishing page:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.contrechoc.com/iphone/ExampleTemplateView4.zip"&gt;ExampleTemplateView4.zip  &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;the bit of code you have to add to get your image on top of  a background:&lt;br /&gt;&lt;br /&gt;UIImageView *imageAdded  =  [[UIImageView alloc]  initWithImage: [UIImage imageNamed:@"myImageName.jpg"]];&lt;br /&gt;[background   addSubview: imageAdded];&lt;br /&gt;imageAdded.center = CGPointMake(160,150);  //position of center&lt;br /&gt;imageAdded.alpha = .7;//transparency&lt;br /&gt;&lt;br /&gt;-----&lt;br /&gt;&lt;br /&gt;the  backgrounds can be found in the file GameOverViewController.m&lt;br /&gt;&lt;br /&gt;under  " - (void)touchesBegan:"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;more  examples and templates on &lt;a href="http://www.iphoneinsandouts.wordpress.com/"&gt;www.iphoneinsandouts.wordpress.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;on this last blog you can find more templates, tricks and design links. We did a class of about ten weeks and we have two app's in the appstore as a result of this. All kind of examples can be found with source code!&lt;br /&gt;&lt;br /&gt;Check out two results: Google on "Aaipet appstore", and  "Chameleon feeder appstore"&lt;br /&gt;&lt;br /&gt;let us all make FREE games for ALL!!!!!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-2947286127243332565?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2947286127243332565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2947286127243332565'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2010/05/some-basic-templates-for-iphone-coding.html' title='Some basic templates for Iphone coding'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-221158161393422492</id><published>2010-02-17T13:11:00.000-08:00</published><updated>2010-02-17T13:12:20.328-08:00</updated><title type='text'>Iphone programming basics</title><content type='html'>Starting with Iphone development you have to get used to some conventions in Objective C.&lt;br /&gt;&lt;br /&gt;First you need some output for debugging in the Debugger Console, this is done with NSLog:&lt;br /&gt;&lt;br /&gt;( By the way, A string is preceeded by @ )&lt;br /&gt;&lt;br /&gt;NSLog(@"read the name");//simple string output in Debugger window.&lt;br /&gt;Where to find this window: here, when you are running.....: (the gdb black window button...)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.wdka.nl/crosslab-diy/files/2010/01/debugger.jpg" title="debugger.jpg"&gt;&lt;img src="http://blog.wdka.nl/crosslab-diy/files/2010/01/debugger.jpg" alt="debugger.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now you can see what your code is doing:&lt;br /&gt;&lt;br /&gt;NSLog(@"look at this number %d", intNumber); //int&lt;br /&gt;NSLog(@"touched loc %f %f",  currentTouch.x ,  currentTouch.y ); //float&lt;br /&gt;&lt;br /&gt;showing a string in NSLog:&lt;br /&gt;done by using stringByAppendingString:&lt;br /&gt;NSLog([@"see how the name of the player is changed in setNamePlayer :" stringByAppendingString:@"new name of  player"]);&lt;br /&gt;&lt;br /&gt;mind the function clammers: [ and ] ..... [ ... stringByAppendingString: ... ], this gives a String, because this comes from the class NSString.&lt;br /&gt;&lt;br /&gt;simple numbers: (no pointers needed)&lt;br /&gt;int, float, bool&lt;br /&gt;int myInt = 9;&lt;br /&gt;float myFloat = 9.123;&lt;br /&gt;bool myBool = false;&lt;br /&gt;&lt;br /&gt;Declaration: int (float, bool)&lt;br /&gt;in the header:&lt;br /&gt;&lt;br /&gt;@interface ScoreObject : NSObject {&lt;br /&gt;int playingFieldNumber;&lt;br /&gt;}&lt;br /&gt;@property int playingFieldNumber;&lt;br /&gt;&lt;br /&gt;in the source:&lt;br /&gt;#import "ScoreObject.h"&lt;br /&gt;@implementation ScoreObject&lt;br /&gt;@synthesize  playingFieldNumber;&lt;br /&gt;&lt;br /&gt;Number Objects: (always pointers in Objective C)&lt;br /&gt;making an Number Object (for instance needed populating NSArray or NSMutableArray&lt;br /&gt;NSNumber*  myNumberObject = [NSNumber numberWithInt: 99 ];&lt;br /&gt;NSNumber*  myNumberObject = [NSNumber numberWithFloat: 99.99 ];&lt;br /&gt;&lt;br /&gt;getting the value back from an NSNumber Object:&lt;br /&gt;int myIntValue = (int)[myNumberObject intValue];&lt;br /&gt;float myFloatValue = (float)[myNumberObject floatValue];&lt;br /&gt;bool myBoolValue = (bool)[myNumberObject boolValue];&lt;br /&gt;&lt;br /&gt;using this in NSLog:&lt;br /&gt;NSLog([@"look at this number %d", (int)[myNumberObject intValue]);&lt;br /&gt;&lt;br /&gt;Declaration: objects like NSNumber, NSArray&lt;br /&gt;in the header&lt;br /&gt;@interface ScoreObject : NSObject {&lt;br /&gt;NSMutableArray *fieldNameArray;&lt;br /&gt;}&lt;br /&gt;@property (nonatomic, retain) NSMutableArray *fieldNameArray;&lt;br /&gt;&lt;br /&gt;in the source:&lt;br /&gt;@implementation ScoreObject&lt;br /&gt;@synthesize  fieldNameArray;&lt;br /&gt;&lt;br /&gt;Last thing about NSLog... how to get an object out?&lt;br /&gt;&lt;br /&gt;NSLog( @"this is my object: %@", myNSNumber );&lt;br /&gt;&lt;br /&gt;of course you do not get a int float bool, like this, but an object name.]]&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-221158161393422492?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/221158161393422492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/221158161393422492'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2010/02/iphone-programming-basics.html' title='Iphone programming basics'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-8125013435795529850</id><published>2010-02-06T23:00:00.000-08:00</published><updated>2010-02-06T23:07:03.165-08:00</updated><title type='text'>Provisioning profile blues</title><content type='html'>I was cooking up exercises now with the provisioning profiles. Just take a new clean view based project, nothing in it but the grey screen and see where you get with the different provisioning profiles, and debug release and distribution on your device.&lt;br /&gt;&lt;br /&gt;Later on I saw someone else already having a full diner of these exercises!&lt;br /&gt;&lt;a href="http://www.codza.com/how-to-fix-iphone-code-signing-errors"&gt;http://www.codza.com/how-to-fix-iphone-code-signing-errors&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Why there are two Info windows, one for the project and the other for the target, why you have to insert again a special Entitlements.plist, why you have this possibility of debugging in the Entitlements but have to uncheck it.....stopping the app running from Xcode on your device....&lt;br /&gt;&lt;br /&gt;I hope sometimes the real apple enlightenment will shine on me...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-8125013435795529850?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8125013435795529850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8125013435795529850'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2010/02/provisioning-profile-blues.html' title='Provisioning profile blues'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-4081845946547697764</id><published>2010-02-03T00:55:00.001-08:00</published><updated>2010-02-03T09:38:23.585-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='provisioning profile'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><category scheme='http://www.blogger.com/atom/ns#' term='Entitlements'/><title type='text'>Iphone Provisioning Profile problems links</title><content type='html'>While trying to submit my app I had to search for links explaining all the details of the weird security system of the Iphone apps, in combination with Xcode.&lt;br /&gt;It really took me days and this signing is much more difficult than programming to get it right.&lt;br /&gt;(Studying relativity theory is easier than getting this right, and a lot more fun!)&lt;br /&gt;&lt;br /&gt;This is a collection of links I found useful:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.24100.net/2009/02/iphone-sdk-mobile-provisioning-0xe800003a-0xe8000001/"&gt;http://www.24100.net/2009/02/iphone-sdk-mobile-provisioning-0xe800003a-0xe8000001/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/5429-codesign-verification-nightmare.html"&gt;http://www.iphonedevsdk.com/forum/iphone-sdk-development/5429-codesign-verification-nightmare.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://johnehartzog.com/2009/04/iphone-app-ad-hoc-gotchas/"&gt;http://johnehartzog.com/2009/04/iphone-app-ad-hoc-gotchas/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The first blog I found with an Entitlements.pList written out is:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://adrianhosey.blogspot.com/2009/01/iphone-development-provisioning.html"&gt;http://adrianhosey.blogspot.com/2009/01/iphone-development-provisioning.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In this blog you get a picture of the contents of this file, only for me:&lt;br /&gt;debugging has to be allowed!!! (in debugging) Other tell to uncheck this.(for release)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jq__kevBr8s/S2my9mAfT_I/AAAAAAAABVk/VdNPdkVJmXY/s1600-h/Image3.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 180px;" src="http://1.bp.blogspot.com/_Jq__kevBr8s/S2my9mAfT_I/AAAAAAAABVk/VdNPdkVJmXY/s400/Image3.jpg" alt="" id="BLOGGER_PHOTO_ID_5434071196643577842" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;In release (device) the app is loaded to my device, but not started, I have to start it myself.&lt;br /&gt;&lt;br /&gt;Then I discovered there were two files with seperate properties: (called Info)&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/S2myadliBSI/AAAAAAAABVU/3vkXIEiu9cY/s1600-h/Image2.jpg"&gt;&lt;img style="cursor: pointer; width: 206px; height: 63px;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/S2myadliBSI/AAAAAAAABVU/3vkXIEiu9cY/s400/Image2.jpg" alt="" id="BLOGGER_PHOTO_ID_5434070593087604002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;double click&lt;/span&gt; on Project to get the Project Properties: Project Info&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jq__kevBr8s/S2myavk3IdI/AAAAAAAABVc/oQUr9q-chEM/s1600-h/Image1.jpg"&gt;&lt;img style="cursor: pointer; width: 210px; height: 115px;" src="http://1.bp.blogspot.com/_Jq__kevBr8s/S2myavk3IdI/AAAAAAAABVc/oQUr9q-chEM/s400/Image1.jpg" alt="" id="BLOGGER_PHOTO_ID_5434070597916631506" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;double click &lt;/span&gt;on the app icon under Target to get the Target properties: Target Info&lt;br /&gt;&lt;br /&gt;These files are practically the same, but the Code Signing Entitlements is &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; taken over!!!&lt;br /&gt;&lt;br /&gt;So for me one was at still at dist.plist the other on Entitlements.plist, giving an error!!!!&lt;br /&gt;&lt;br /&gt;So we should set SIX files the right way.... (debug release distribution, for simulator and for device.....)&lt;br /&gt;Who has cooked this system up?&lt;br /&gt;&lt;br /&gt;It must have been the Tetris God, messing up!&lt;br /&gt; (see him here: &lt;a href="http://www.youtube.com/watch?v=Alw5hs0chj0" target="_blank"&gt;http://www.youtube.com/watch?v=Alw5hs0chj0&lt;/a&gt;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-4081845946547697764?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4081845946547697764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4081845946547697764'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2010/02/iphone-provisioning-profile-problems.html' title='Iphone Provisioning Profile problems links'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Jq__kevBr8s/S2my9mAfT_I/AAAAAAAABVk/VdNPdkVJmXY/s72-c/Image3.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-2570258506705768738</id><published>2009-12-24T22:36:00.000-08:00</published><updated>2009-12-24T23:14:00.765-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='double free'/><category scheme='http://www.blogger.com/atom/ns#' term='malloc'/><category scheme='http://www.blogger.com/atom/ns#' term='release'/><category scheme='http://www.blogger.com/atom/ns#' term='DebuggingAutorelease'/><title type='text'>Debugging a double free malloc error</title><content type='html'>When making an instance you have to free it again with release. But there is also for some familiar things like CGArray an auto release.&lt;br /&gt;I had an error in the Debugging Window telling me there was a double release....&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;malloc: *** error for object 0x1346f90: double free&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;*** set a breakpoint in malloc_error_break to debug&lt;/span&gt;&lt;br /&gt;where to put what breakpoint?&lt;br /&gt;in gdb? well somehow this didn't work for me.&lt;br /&gt;&lt;br /&gt;The problem is of course the object is released later on, not stopping at the line which caused the problem....&lt;br /&gt;&lt;br /&gt;these links helped me setting the environmental variables needed to debug:&lt;br /&gt;&lt;a href="http://lists.apple.com/archives/Xcode-users/2008/Apr/msg00160.html"&gt;http://lists.apple.com/archives/Xcode-users/2008/Apr/msg00160.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cocoadev.com/index.pl?DebuggingAutorelease"&gt;http://www.cocoadev.com/index.pl?DebuggingAutorelease&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cocoadev.com/index.pl?MallocStackLogging"&gt;http://www.cocoadev.com/index.pl?MallocStackLogging&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cocoadev.com/index.pl?NSZombieEnabled"&gt;http://www.cocoadev.com/index.pl?NSZombieEnabled&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cocoadev.com/index.pl?DebuggingTechniques"&gt;http://www.cocoadev.com/index.pl?DebuggingTechniques&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;after setting the environmental variables given in the link I got this error:&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;*** -[CFArray release]: message sent to deallocated instance 0x135e0a0&lt;/span&gt;&lt;br /&gt;which didn't tell me anything new, the instance number I could not trace...&lt;br /&gt;the debugger told me this:&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;malloc: stack logs being written into /tmp/stack-logs.373.Grungegolf.KT6xux&lt;/span&gt;&lt;br /&gt;but where is this file situated?&lt;br /&gt;&lt;br /&gt;this command didn't help because the pin number  (in this example 3939) from this example is not in my gdb error&lt;br /&gt;&lt;pre&gt;shell malloc_history 3939 0xa4e10&lt;/pre&gt;this didn't help either:&lt;br /&gt;gdb: t a a bt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;in the end I searched for all the release commands I have given with the only clue that is must be an Array, and I found the culprit...&lt;br /&gt;&lt;br /&gt;trying to understand:&lt;br /&gt;I loaded a textfile:&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;NSString *myText = [NSString stringWithContentsOfFile:whateverFilePathString];&lt;/span&gt;&lt;br /&gt;I used this to load my game fields, being all in the textFile, a String&lt;br /&gt;so seperate the fields:&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;NSArray *allData = [myText componentsSeparatedByString:@"***"];&lt;/span&gt;&lt;br /&gt;with the separator "***"&lt;br /&gt;then taking element 3 which contained the bouncers...&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;NSArray *bouncerData = [[allData objectAtIndex:2] componentsSeparatedByString:@","];&lt;/span&gt;&lt;br /&gt;putting the bouncer data, making them numbers in another array of objects...&lt;br /&gt;I released the bouncerData (wrong!)&lt;br /&gt;I suppose this bouncerData array is released with the allData array, which is also released automatically....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-2570258506705768738?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2570258506705768738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2570258506705768738'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/12/debugging-double-free-malloc-error.html' title='Debugging a double free malloc error'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-7148159082699608068</id><published>2009-10-27T01:02:00.000-07:00</published><updated>2009-10-27T01:09:48.382-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xcode'/><title type='text'>NSArray features</title><content type='html'>&lt;span style="font-family: arial;"&gt;We had an NSArray of objects of the type UIImageView.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;the array was retained being a property etc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;initialize like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;testBall2Array = [NSMutableArray arrayWithObjects:  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]], &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;[[UIImageView alloc] initWithImage: [UIImage imageNamed:@"testBall2.png"]],&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;                      nil];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;We succeeded in putting the views on screen in the same method but apparently in another method we got a bad access error when doing something with an element of this array.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;The elements were not retained, but how to retain them?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;This is one of the niceties of Xcode!   :-(((&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;The answer is found here:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://stackoverflow.com/questions/519467/iphone-getting-the-uiimageview-back-from-nsarray"&gt;http://stackoverflow.com/questions/519467/iphone-getting-the-uiimageview-back-from-nsarray&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;you have to initialize with a different method:&lt;/span&gt;&lt;br /&gt;&lt;pre style="font-family: arial;" class="prettyprint"&gt;&lt;code&gt;&lt;span class="pln"&gt;initWithObjects&lt;/span&gt;&lt;span class="pun"&gt;&lt;br /&gt;&lt;br /&gt;instead of&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span class="pln"&gt;arrayWithObjects&lt;/span&gt;&lt;span class="pun"&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;the first retains the objects the second doesn't......&lt;br /&gt;&lt;br /&gt;well this is the way you spent your time doing Xcode....&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-7148159082699608068?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7148159082699608068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7148159082699608068'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/10/nsarray-features.html' title='NSArray features'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-4682389964831123746</id><published>2009-10-24T04:58:00.000-07:00</published><updated>2009-10-24T05:11:13.694-07:00</updated><title type='text'>NSMutableArray and CGPointArray</title><content type='html'>We wanted to set up an array of CGPoints but failed, in the properties....&lt;br /&gt;We had to do it with a NSMutableArray. But how to get the CGPoints in?&lt;br /&gt;&lt;br /&gt;the answer is found here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/943945/how-to-form-cgpoint-array-in-objective-c"&gt;http://stackoverflow.com/questions/943945/how-to-form-cgpoint-array-in-objective-c&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;so:&lt;br /&gt;&lt;br /&gt;@interface OrbitLinesDrawView : UIView {&lt;br /&gt;&lt;br /&gt;UIColor *strokeColor;&lt;br /&gt;UIColor *rectColor;&lt;br /&gt;CGFloat strokeWidth;&lt;br /&gt;CGFloat cornerRadius;&lt;br /&gt;&lt;br /&gt;NSMutableArray* orbitLinePointsArray ;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@property (nonatomic, retain) NSMutableArray* orbitLinePointsArray ;&lt;br /&gt;&lt;br /&gt;and then in the .m file:&lt;br /&gt;&lt;br /&gt;@synthesize orbitLinePointsArray;&lt;br /&gt;&lt;br /&gt;in the init:&lt;br /&gt;&lt;br /&gt;orbitLinePointsArray = [[NSMutableArray alloc]init ];&lt;br /&gt;&lt;br /&gt;for (int i = 0; ... etc....)&lt;br /&gt;CGPoint aPoint = CGPointMake(100 - 10*i, 200+10*i);&lt;br /&gt;NSValue* pointValueObject = [NSValue valueWithCGPoint:aPoint];&lt;br /&gt;[orbitLinePointsArray addObject:(NSValue*)pointValueObject];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;(dont forget to alloc the orbitLinePointsArray)&lt;br /&gt;&lt;br /&gt;for setting the CGPoints later on:&lt;br /&gt;&lt;br /&gt;-(void)setObjectInPointArray: (int)positionInArray : (CGPoint) myPoint&lt;br /&gt;{&lt;br /&gt;NSValue* pointValueObject = [NSValue valueWithCGPoint:myPoint];&lt;br /&gt;[ orbitLinePointsArray replaceObjectAtIndex:positionInArray withObject:pointValueObject ];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;drawing the points in the&lt;br /&gt;&lt;br /&gt;-(void)drawLines {&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;CGPoint lineArray[2];&lt;br /&gt;&lt;br /&gt;for(int i=0 ; ... etc....)&lt;br /&gt;{&lt;br /&gt;lineArray[0] = ((CGPoint) [[orbitLinePointsArray objectAtIndex:i] CGPointValue]);&lt;br /&gt;lineArray[1] = ((CGPoint) [[orbitLinePointsArray objectAtIndex:i+1] CGPointValue]);&lt;br /&gt;&lt;br /&gt;CGContextAddLines ( context, lineArray, 2 );&lt;br /&gt;CGContextStrokePath(context);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;[self setNeedsDisplay];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;- (void)drawRect:(CGRect)rect {&lt;br /&gt;&lt;br /&gt;[ self drawLines ];&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;so Objective C, Cocoa, ....whatever....wrap it up in further and further objects, that seems to be Apple.....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-4682389964831123746?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4682389964831123746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4682389964831123746'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/10/nsmutablearray-and-cgpointarray.html' title='NSMutableArray and CGPointArray'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-652888871179089216</id><published>2009-08-21T22:05:00.000-07:00</published><updated>2009-08-22T03:37:16.521-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><category scheme='http://www.blogger.com/atom/ns#' term='betatest'/><title type='text'>beta testing on the iphone</title><content type='html'>a list of probably useful links for setting up a beta test of a new app on the iphone:&lt;br /&gt;&lt;br /&gt;the most important word is "Ad Hoc"&lt;br /&gt;&lt;br /&gt;maybe the best is just to follow the list in the developer.apple.com -&gt; program portal -&gt; Distribution tab (in the link of team, certificates, devices, app id's , provisioning)&lt;br /&gt;the problem is that I at least tend to search the web for links about this subject before looking in the apple dev portal....&lt;br /&gt;&lt;br /&gt;in distribution tab open up the prepare tab and read the steps...&lt;br /&gt;&lt;br /&gt;problem with me was the key - distribution profile combination&lt;br /&gt;in xcode in projectpreferences the distribution profile was indicated but also the error of no combination of key and profile found&lt;br /&gt;in the keychain i had to select a private key and drag the profile into it, than the key was combined with the profile like on the image:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jq__kevBr8s/So_KQtY6S8I/AAAAAAAABVI/IrZaY5kLK_o/s1600-h/key-profile.jpg"&gt;&lt;img style="cursor: pointer; width: 388px; height: 251px;" src="http://2.bp.blogspot.com/_Jq__kevBr8s/So_KQtY6S8I/AAAAAAAABVI/IrZaY5kLK_o/s400/key-profile.jpg" alt="" id="BLOGGER_PHOTO_ID_5372735268887088066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;other not apple link info:&lt;br /&gt;&lt;br /&gt;intro:&lt;br /&gt;&lt;a href="http://www.appletell.com/apple/comment/app-store-development-part-2-provisioning-and-ad-hoc/"&gt;http://www.appletell.com/apple/comment/app-store-development-part-2-provisioning-and-ad-hoc/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.appletell.com/apple/comment/iphone-developer-intervention-week-7-beta-testing/"&gt;http://www.appletell.com/apple/comment/iphone-developer-intervention-week-7-beta-testing/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;how to make an ad hoc provisioning profile:&lt;br /&gt;&lt;a href="http://www.manyfriends.com/wiki/iphone/index.php/Create_an_ad-hoc_provisioning_profile#Create_the_ad-hoc_profile"&gt;http://www.manyfriends.com/wiki/iphone/index.php/Create_an_ad-hoc_provisioning_profile#Create_the_ad-hoc_profile&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;a list of steps to follow after that&lt;br /&gt;&lt;a href="http://furbo.org/2008/08/06/beta-testing-on-iphone-20/"&gt;http://furbo.org/2008/08/06/beta-testing-on-iphone-20/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;a free app to use to get betatester to send you the UDID&lt;br /&gt;&lt;a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=285691333&amp;amp;mt=8"&gt;http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=285691333&amp;amp;mt=8&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;there is a site for global beta testing (not tested by us yet:-)&lt;br /&gt;&lt;a href="http://ibetatest.com/iphone/controllers/welcome/"&gt;http://ibetatest.com/iphone/controllers/welcome/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-652888871179089216?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/652888871179089216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/652888871179089216'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/08/beta-testing-on-iphone.html' title='beta testing on the iphone'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Jq__kevBr8s/So_KQtY6S8I/AAAAAAAABVI/IrZaY5kLK_o/s72-c/key-profile.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-797795983963178778</id><published>2009-06-22T22:42:00.000-07:00</published><updated>2009-06-22T22:49:33.136-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sound'/><category scheme='http://www.blogger.com/atom/ns#' term='terminal'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><title type='text'>Sound on the Iphone</title><content type='html'>Having lot's of trouble gettting a good sound for my game on the iPhone, due to the special sound format. The Iphone explanation didn't help much, the code is clear, no it was the formatting.&lt;br /&gt;I got a sound ending in a terrible noise, when played on the Iphone.&lt;br /&gt;&lt;br /&gt;Finally i found the right links, explaining and suggesting the solution:&lt;br /&gt;&lt;a href="http://www.wooji-juice.com/blog/iphone-openal-ima4-adpcm.html"&gt;http://www.wooji-juice.com/blog/iphone-openal-ima4-adpcm.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;here something is told about the &lt;span class="page"&gt;&lt;/span&gt;&lt;a name="2"&gt;&lt;span style="font-weight: bold;"&gt;IMA4 &lt;/span&gt;format, and alos how to get it using the terminal window:&lt;br /&gt;&lt;br /&gt;&lt;span class="page"&gt;&lt;code&gt;afconvert -f caff -d ima4 audiofile.wav&lt;br /&gt;&lt;br /&gt;usinf this command i got a sound working normally in my game.&lt;br /&gt;&lt;br /&gt;You have to know how to use the terminal in Mac OS (personally i am a Windows user :-)&lt;br /&gt;&lt;br /&gt;here is a link explaining how to get in the right directory:&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href="http://macapper.com/2007/03/08/the-terminal-an-introduction/"&gt;http://macapper.com/2007/03/08/the-terminal-an-introduction/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;this amounts to:&lt;br /&gt;opening the terminal using spotlight...&lt;br /&gt;cd Desk*&lt;br /&gt;cd FileWithSoundOnDeskTop&lt;br /&gt;and then the command above afconvert&lt;br /&gt;&lt;br /&gt;So in the end, all was already on my MACBOOK (with the double booth) only I had to find it...&lt;br /&gt;&lt;br /&gt;have fun!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-797795983963178778?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/797795983963178778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/797795983963178778'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/06/sound-on-iphone.html' title='Sound on the Iphone'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-3140241091075085650</id><published>2009-04-21T17:01:00.000-07:00</published><updated>2009-04-21T17:54:52.381-07:00</updated><title type='text'>C special on arrays and functions</title><content type='html'>&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;Introductions of C can be found on the internet. These explain basic stuff like pointrs and arrays. But programming a bit for the nds, you need details which are not in the introductions.&lt;br /&gt;&lt;br /&gt;Programming in Programmers Notepad with testing in an emulator (all for the nds in C) is not the easiest way of experimenting. So sometimes i write some test code in Dev Cpp.&lt;br /&gt;&lt;br /&gt;This is an example: for one of the field in a minigolf game you need an array. This array must be initiated in a struct. This struct has a function making this initialization. Many possibilities of doing this, of course. One of the possibilitites is shown here:&lt;br /&gt;&lt;br /&gt;This is (part of ) the struct: (in a header file)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;typedef struct Field{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    int pointsList[200];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;     int roundNr;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;}FIELD;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;extern FIELD makeField( FIELD myField,  int p[ ]);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;extern void printField(FIELD myField);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;The function is found in the source file: see especially how the array is called. p[ ] is a pointer.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;FIELD makeField(FIELD myField, int p[ ], pSize)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   myField.roundNr = 4;//just some value for this example&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   int c1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   for ( c1=0; c1 &lt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;pSize&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  ; c1++ )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     myField.pointsList[c1] = (int)p[c1]   ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     printf("value from field make function %d \n  " ,(int)p[c1]  ); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     return myField; //necessary to get the object back, this is C&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;void printField(FIELD myField)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   int c1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   for ( c1=0; c1 &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     printf("from print %d \n",(int)myField.pointsList[c1] )  ; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;then the main file:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;#define NUM_ELEM(x) (sizeof (x) / sizeof (*(x))) //this trick is explained see below&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int main(int argc, char *argv[])&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;     FIELD myField;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      int p[ ] = {1,2,3,4,5,6,7,8,9,0};&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      myField = makeField(  myField,  p, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial; color: rgb(0, 102, 0);"&gt;&lt;span style="font-family: arial;"&gt;NUM_ELEM(&lt;/span&gt;&lt;span style="font-family: arial;"&gt;p&lt;/span&gt;&lt;span style="font-family: arial;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;); //return because of passing by value&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;     printField( myField);//check&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;the &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;NUM_ELEM is explained in &lt;a href="http://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays#Pointers_in_Function_Arguments"&gt;http://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays#Pointers_in_Function_Arguments&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;nearly at the end of this page.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;You see how the array is passed to the function, how the struct object is filled with the array. All kinds of little C details dealing with the not OO world!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;Of course you can do this in another way, not returning the field, you have to use a pointer to this struct:&lt;br /&gt;&lt;br /&gt;in the main:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;FIELD * myFieldPointer;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;myFieldPointer = &amp;secondField;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int p2[] = {11,12,13,14,15,16,17,18,19,20};&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;makeFieldPointer( myFieldPointer,  p2, NUM_ELEM(p2) ); //not returning because of passing by reference&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;printField( secondField);//check&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;You need another function &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;makeFieldPointer:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;void makeFieldPointer( FIELD *myFieldPointer,  int p[ ], int sizeP)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     myFieldPointer-&gt;roundNr = 4; //need the -&gt; because of the pointer&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    int c1;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     for ( c1=0; c1 &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     myFieldPointer-&gt;pointsList[c1] = (int)p[c1]   ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     printf("value from &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial; color: rgb(0, 0, 153);"&gt;&lt;span style="font-family: arial;"&gt;makeFieldPointer&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; %d \n  " ,(int)p[c1]  ); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;     }    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-3140241091075085650?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3140241091075085650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3140241091075085650'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/04/c-special-on-arrays-and-functions.html' title='C special on arrays and functions'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-7884162904643537665</id><published>2009-04-21T16:55:00.001-07:00</published><updated>2009-04-21T17:01:44.235-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='update'/><category scheme='http://www.blogger.com/atom/ns#' term='devkitpro'/><title type='text'>Latest DevKitPro</title><content type='html'>&lt;span style="font-family: arial;"&gt;Devkitpro is updated. This means getting used to some changes, in naming, some new functions, some new possibilities. Not always what you are waiting for! But ok, here some pages which make life easier:&lt;br /&gt;&lt;br /&gt;Tis is a page with a usefull list of registers:&lt;br /&gt;&lt;a href="http://www.coranac.com/2008/09/11/nds-register-overview/"&gt;http://www.coranac.com/2008/09/11/nds-register-overview/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;then this page under point 10 explains other changes:&lt;br /&gt;&lt;a href="http://quirkygba.blogspot.com/2008/12/upgrading-to-devkitarm-r24-on-linux.html"&gt;http://quirkygba.blogspot.com/2008/12/upgrading-to-devkitarm-r24-on-linux.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;if the registers, for instance of backgrounds are changed, and the irqinit() is removed, most of the stuff works as before. I had more difficulties getting the maxmod sounds work with the DSerial, since both of this is going through the ARM7 apparently.....my solution was statistics, but that is not very neat....&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-7884162904643537665?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7884162904643537665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7884162904643537665'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/04/latest-devkitpro.html' title='Latest DevKitPro'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-7747679918594879023</id><published>2009-04-12T07:33:00.000-07:00</published><updated>2009-04-12T08:10:17.672-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='writing file'/><category scheme='http://www.blogger.com/atom/ns#' term='reading file'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>Using libfat</title><content type='html'>The example in de devkitpro prints the directory of the card.&lt;br /&gt;It only runs on the ds itself, not in the emulator i use....:-(&lt;br /&gt;&lt;br /&gt;ok this is a diary, just stating the things needed and where i found these: i needed to read in the integers describing the points of the triangulation for the minigolf game fields.&lt;br /&gt;&lt;br /&gt;the libfat example only described reading the directory.&lt;br /&gt;&lt;br /&gt;I found an example of really reading in a textfile here: (actually it is written for the wii, but who cares?)&lt;br /&gt;&lt;a href="http://www.codemii.com/2009/03/02/tutorial-10-using-the-filesystem/"&gt;http://www.codemii.com/2009/03/02/tutorial-10-using-the-filesystem/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and the functions to read a txt file are: (adding to the example in the devkitpro)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void die(char *msg) {&lt;br /&gt;perror(msg);&lt;br /&gt;fatUnmount(0);&lt;br /&gt;exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void readFile()&lt;br /&gt;{&lt;br /&gt;        FILE *f = fopen ("hello.txt", "rb");// If file doesn't exist or can't open it then we can grab the latest file&lt;br /&gt;        if (f == NULL) {&lt;br /&gt;                die("Could not open myfile.txt file for reading.\n");&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                else {&lt;br /&gt;                    char file_line [20];&lt;br /&gt;                    int line_number = 0;&lt;br /&gt;                    while (fgets (file_line, 20, f)) {&lt;br /&gt;                        printf("Line %i: %s\n",line_number, file_line);&lt;br /&gt;                        line_number++;&lt;br /&gt;                    }&lt;br /&gt;                    fclose(f);&lt;br /&gt;                }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;as explained (and needed for my minigolf, reading in the triangulations of the fields)&lt;br /&gt;you can easily read in and distribute integers to arrays lik this:&lt;br /&gt;&lt;br /&gt;make these arrays global, for instance&lt;br /&gt;&lt;br /&gt;int x_pos[] = { 0, 0, 0, 0, 0};&lt;br /&gt;int y_pos[] = { 0, 0, 0, 0, 0};&lt;br /&gt;&lt;br /&gt;void readFile()&lt;br /&gt;{&lt;br /&gt;         FILE *f = fopen ("hello.txt", "rb");&lt;br /&gt;         // If file doesn't exist or can't open it then we can grab the latest file&lt;br /&gt;         if (f == NULL) {&lt;br /&gt;                 die("Could not open myfile.txt file for reading.\n");&lt;br /&gt;                 }&lt;br /&gt;                 else {&lt;br /&gt;                     char file_line [20];&lt;br /&gt;                     int line_number = 0;&lt;br /&gt;                     while (fgets (file_line, 20, f)) {&lt;br /&gt;                         printf("Line %i: %s\n",line_number, file_line);&lt;br /&gt;&lt;br /&gt;                         char *temp_string;&lt;br /&gt;                         temp_string = strtok (file_line, " ");&lt;br /&gt;                         if (temp_string != NULL) {&lt;br /&gt;                             x_pos[line_number] = atoi(temp_string);&lt;br /&gt;                             temp_string = strtok (NULL, " ");&lt;br /&gt;                             if (temp_string != NULL) {&lt;br /&gt;                                 y_pos[line_number] = atoi(temp_string);&lt;br /&gt;                             }&lt;br /&gt;                         }&lt;br /&gt;                         line_number++;&lt;br /&gt;                     }&lt;br /&gt;                     fclose(f);&lt;br /&gt;                 }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;which still prints the values as a check, this can be left out.&lt;br /&gt;&lt;br /&gt;Writing to a file is also described above, which is useful for a highscore, eventually.&lt;br /&gt;&lt;br /&gt;Writing in the example went well, but for the fact that the integers were written without a space, so the lines glued together.&lt;br /&gt;&lt;br /&gt;This was solved adding:&lt;br /&gt;char end_string[2] = { 0x0D, 0x0A};&lt;br /&gt;fputs (end_string ,f);&lt;br /&gt;&lt;br /&gt;so the function becomes:&lt;br /&gt;&lt;br /&gt;void writeFile()&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   FILE *f = fopen ("myScorefile.txt", "wb");&lt;br /&gt;&lt;br /&gt;   int line_number = 5;&lt;br /&gt;&lt;br /&gt;   if (f == NULL) {&lt;br /&gt;       die("Could not open myScorefile.txt file for writing.\n");&lt;br /&gt;   }&lt;br /&gt;   else {&lt;br /&gt;       int x;&lt;br /&gt;       for (x = 0; x &lt; line_number; x++) {&lt;br /&gt;           char temp_string[20];&lt;br /&gt;           sprintf(temp_string, "%i %i", x_pos[x], y_pos[x]);&lt;br /&gt;           fputs (temp_string ,f);&lt;br /&gt;           char end_string[2] = { 0x0D, 0x0A};&lt;br /&gt;           fputs (end_string ,f);&lt;br /&gt;       }&lt;br /&gt;       fclose(f);&lt;br /&gt;   }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-7747679918594879023?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7747679918594879023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7747679918594879023'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/04/using-libfat.html' title='Using libfat'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-2881936320610294982</id><published>2009-04-01T12:11:00.000-07:00</published><updated>2009-04-01T12:20:52.757-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sound'/><category scheme='http://www.blogger.com/atom/ns#' term='maxmod'/><category scheme='http://www.blogger.com/atom/ns#' term='DSerial Edge'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>DSerial Edge</title><content type='html'>&lt;h1 style="font-family: arial;" class="firstHeading"&gt;&lt;span style="font-weight: normal;font-size:100%;" &gt;DSerial Edge &lt;span style="font-family: arial;"&gt;is something very interesting. It can make the nds explore the outer world!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/h1&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;documentation is found here: &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.natrium42.com/wiki/DSerial_Edge"&gt;http://www.natrium42.com/wiki/DSerial_Edge&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;we did a first project linking switches made in or from books with an app on the nds&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;the only problem is at the moment:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;dserial libs and maxmod sound  libs interfere somewhere, so working with dserial limits the nds possibilities seriously!&lt;br /&gt;&lt;br /&gt;On a small testapp, we connected the ports of IO1 to HIGH. This works fine, when a low is presented a low is seen:  &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.contrechoc.com/flash/basic-keyboard.zip"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;dsePinWrite(0, 6, true);&lt;br /&gt;    dsePinWrite(0, 7, true);&lt;br /&gt;    dsePinWrite(1, 1, true);&lt;br /&gt;    dsePinWrite(1, 0, true);&lt;br /&gt;    dsePinWrite(1, 2, true);&lt;br /&gt;    dsePinWrite(1, 4, true);&lt;br /&gt;    dsePinWrite(1, 5, true);&lt;br /&gt;    dsePinWrite(1, 6, true);&lt;br /&gt;    dsePinWrite(1, 7, true);&lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt;    dsePinMode(0, 6, INPUT);&lt;br /&gt;    dsePinMode(0, 7, INPUT);&lt;br /&gt;    dsePinMode(1, 1, INPUT);&lt;br /&gt;    dsePinMode(1, 0, INPUT);&lt;br /&gt;    dsePinMode(1, 2, INPUT);&lt;br /&gt;    dsePinMode(1, 3, INPUT);&lt;br /&gt;    dsePinMode(1, 4, INPUT);&lt;br /&gt;    dsePinMode(1, 5, INPUT);&lt;br /&gt;    dsePinMode(1, 6, INPUT);&lt;br /&gt;    dsePinMode(1, 7, INPUT);&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;When playing sounds, the ports are steered LOW by the sounds...using the same ARM7 ????&lt;br /&gt;&lt;br /&gt;this goes very fast, iif this is played in the loop:&lt;br /&gt;&lt;br /&gt;        if( dsePinRead(0, 6)) iprintf("\x1b[6;0H 06=HIGH"); else iprintf("\x1b[6;0H 06=LOW");&lt;br /&gt;        if( dsePinRead(0, 7)) iprintf("\x1b[7;0H 07=HIGH"); else iprintf("\x1b[7;0H 07=LOW");&lt;br /&gt;       &lt;br /&gt;        if( dsePinRead(1, 0)) iprintf("\x1b[9;0H 10=HIGH"); else iprintf("\x1b[9;0H 10=LOW");&lt;br /&gt;        if( dsePinRead(1, 1)) iprintf("\x1b[10;0H 11=HIGH"); else iprintf("\x1b[10;0H 11=LOW");&lt;br /&gt;       &lt;br /&gt;        if( dsePinRead(1, 2)) iprintf("\x1b[11;0H 12=HIGH"); else iprintf("\x1b[11;0H 12=LOW");&lt;br /&gt;        if( dsePinRead(1, 3)) iprintf("\x1b[12;0H 13=HIGH"); else iprintf("\x1b[12;0H 13=LOW");&lt;br /&gt;       &lt;br /&gt;        if( dsePinRead(1, 4)) iprintf("\x1b[13;0H 14=HIGH"); else iprintf("\x1b[13;0H 14=LOW");&lt;br /&gt;        if( dsePinRead(1, 5)) iprintf("\x1b[14;0H 15=HIGH"); else iprintf("\x1b[14;0H 15=LOW");&lt;br /&gt;       &lt;br /&gt;        if( dsePinRead(1, 6)) iprintf("\x1b[16;0H 16=HIGH"); else iprintf("\x1b[16;0H 16=LOW");&lt;br /&gt;        if( dsePinRead(1, 7)) iprintf("\x1b[17;0H 17=HIGH"); else iprintf("\x1b[17;0H 17=LOW");&lt;br /&gt;&lt;br /&gt;then you barely see it, but placing this:&lt;br /&gt;&lt;br /&gt;        if( !dsePinRead(0, 6)) iprintf("\x1b[6;0H 06=LOW");&lt;br /&gt;        if( !dsePinRead(0, 7))  iprintf("\x1b[7;0H 07=LOW");&lt;br /&gt;       &lt;br /&gt;        if( !dsePinRead(1, 0))  iprintf("\x1b[9;0H 10=LOW");&lt;br /&gt;        if( !dsePinRead(1, 1)) iprintf("\x1b[10;0H 11=LOW");&lt;br /&gt;       &lt;br /&gt;        if( !dsePinRead(1, 2))  iprintf("\x1b[11;0H 12=LOW");&lt;br /&gt;        if( !dsePinRead(1, 3))  iprintf("\x1b[12;0H 13=LOW");&lt;br /&gt;       &lt;br /&gt;        if( !dsePinRead(1, 4))   iprintf("\x1b[13;0H 14=LOW");&lt;br /&gt;        if( !dsePinRead(1, 5))  iprintf("\x1b[14;0H 15=LOW");&lt;br /&gt;       &lt;br /&gt;        if( !dsePinRead(1, 6))  iprintf("\x1b[16;0H 16=LOW");&lt;br /&gt;        if( !dsePinRead(1, 7))  iprintf("\x1b[17;0H 17=LOW");&lt;br /&gt;&lt;br /&gt;all go low immediately. This speed can make a work around, only triggering on longer intervals of LOW?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;anyone a more fundamental solution?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-2881936320610294982?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2881936320610294982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2881936320610294982'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/04/dserial-edge.html' title='DSerial Edge'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-1371826255757231667</id><published>2009-02-27T03:55:00.000-08:00</published><updated>2009-03-06T22:56:21.025-08:00</updated><title type='text'>workshop C II</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;In the first workshop we saw that C was about the same as JAVA, although C is not object orientated, in this workshop we see that there are a few differences...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;To start with a real hurdle coming form JAVA we look at pointers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;pointers&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://home.netcom.com/%7Etjensen/ptr/pointers.htm"&gt;&lt;span style="font-family:arial;"&gt;http://home.netcom.com/~tjensen/ptr/pointers.htm&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;a pointer variable refers to an address in memory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int k; //makes an integer, not setting the value yet.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int *ptr;//makes an address variable, not setting this address either&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;//set aside however many bytes is required to store an address in memory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;ptr = &amp;k; //give the address variable the value of the address of the integer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;*ptr = 7; //* is here the dereferencing operator&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;k = 7;//this last two lines have the same effect&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;pointer arithmetic is based on the size of the pointer's type&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;ptr++;//refers to the next address in memory, but shifts the space of an integer.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;short m;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;short *ptrShort = 6;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;ptrShort++;//this would shift the space of a short&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;C will not permit the comparison of a pointer to type integer with a pointer to type character&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;that is why there are "void pointers"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;void *vptr;// a generic pointer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;sizeof(int)&lt;/span&gt;&lt;/span&gt; is a function which returns the number of bytes used by the type provided. This is typically used in pointer arithmetic.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-family:arial;"&gt;arrays&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Arrays were introduced in workshop 1. But there is more than meets the eye, because arrays are big structures and for these structures C uses pointers.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;So arrays and pointers are very related.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;this is still like JAVA:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int my_array[] = {1,23,17,4,-5,100}; //integers stored continuously&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;But now we see the difference:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int *ptr;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;ptr = &amp;amp;my_array[0];       /* point our pointer at the first integer in our array */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int i = 2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;my_array[i] refers to the same variable as *(ptr + i)) : 17&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;note: an arrayname is a pointer, although it seems a "normal: variable:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&amp;amp;arrayName[0] can be replaced with arrayName&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;then there is a curious C effect:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;char myArray[5] = {'h', 'o', 'm', 'e', 'b', 'r', 'e', 'w', '\0'};&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;myArray[3] = *(myArray + 3) = 'm';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;3[myArray] = 'm'; // because *(i + a ) = *( a + i) !&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;remember the multidimensional array? This is a pointer thing too, of course:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;char multi[5][10];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;*(*(multi + row) + col) is the same as multi[row][col]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;because the elements are stored continuously in memory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;to work with "raw" pointers, in pointerarithmetic and wanting to know exactly the place of a variable you use &lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;sizeof(int).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-family:arial;"&gt;structs&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;a href="http://computer.howstuffworks.com/c31.htm"&gt;http://computer.howstuffworks.com/c31.htm&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cprogramming.com/tutorial/lesson7.html"&gt;http://www.cprogramming.com/tutorial/lesson7.ht&lt;/a&gt;ml&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Although there are no objects, we can make or own complex variables, with members:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;You can write your own data structure!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;example:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;typedef struct Triangle{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;POINT p[3]; //member in this case another struct,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;LINE l[3];//another struct as a member&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int t[5];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int neighbours[25];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int outsidePoint[25];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int bouncers[25];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int neighbourNumber;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int outsideNumber;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int bouncerNumber;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}TRIANGLE; //this gives the struct a special name.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;//so POINT en LINE zijn andere structs (convention = capitalized name)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;struct Triangle myTriangle;//declaration or&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;TRIANGLE myTriangle;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;members are defined with a point:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;myTriangle.bouncerNumber = 7;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;if you have a function you pass not the struct but a pointer to the struct:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;*TRIANGLE myTrianglePointer;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;myTrianglePointer = &amp;myTriangle;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;defining a member would become:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;(*myTrianglePointer).bouncerNumber = 63;//but this can be written as:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;myTrianglePointer-&gt; bouncerNumber = 63;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;strings/characters&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;a string is an array of characters terminated by '\0'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;char my_string[40];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   my_string[0] = 'T';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   my_string[1] = 'e';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   my_string[2] = 'd':&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   my_string[3] = '\0';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;char my_string[40] = {'T', 'e', 'd', '\0',};  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;char my_string[40] = "Ted";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;all these lines do the same thing, mind the different quotes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;standard string functions:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   strcopy();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   strlen();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   strcat();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   strchr();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;functions&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;We already know of the pointer, and why we use pointers. In functions this is used:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Never send the struct itself, but always a pointer to the struct.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Of course this means that the struct itself will be changed in the function.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;This is the difference:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;passing by value&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;passing by reference -&gt; pointers&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;since an arrayName is a pointer, fie(arrayName) passes the array by reference.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;header files&lt;br /&gt;&lt;span style="font-size:85%;"&gt;You can write your whole project in the main, using functions on top (above) the main.&lt;br /&gt;This can become rather a mess.&lt;br /&gt;In C you can order your project in files seperated from the main.m&lt;br /&gt;&lt;br /&gt;For instance, you can have a game.m file.&lt;br /&gt;Then you have a header file for initialization of the functions used in the game.m file: game.h&lt;br /&gt;&lt;br /&gt;the header files are collected in the folder called include, and the .m files in a folder called source.&lt;br /&gt;&lt;br /&gt;You have to include the header files to let other files see the functions.&lt;br /&gt;&lt;br /&gt;A problem can be that a header file is included several times, therefore in C you use a special header definition:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;pre&gt;&lt;u&gt;ifndef&lt;br /&gt;&lt;/u&gt;#&lt;u&gt;define&lt;/u&gt;&lt;br /&gt;...&lt;br /&gt;#&lt;u&gt;endif&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; this prevents including the header twice, which would cause an error on function twice defined.&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;pre&gt;#&lt;u&gt;ifndef&lt;/u&gt; __BACKGROUND_H__&lt;br /&gt;#&lt;u&gt;define&lt;/u&gt; __BACKGROUND_H__&lt;br /&gt;&lt;br /&gt;#&lt;u&gt;include&lt;/u&gt; &lt;nds.h&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;extern&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; initBackgrounds();&lt;br /&gt;&lt;b&gt;extern&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; fadeBackground(&lt;b&gt;short&lt;/b&gt; screen, &lt;b&gt;bool&lt;/b&gt; hide);&lt;br /&gt;&lt;b&gt;extern&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; setBitmapBackground(&lt;b&gt;short&lt;/b&gt; screen, &lt;b&gt;const&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; *bitmapData, &lt;b&gt;int&lt;/b&gt; bitmapSize);&lt;br /&gt;&lt;b&gt;extern&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; setTiledBackground(&lt;b&gt;short&lt;/b&gt; screen, &lt;b&gt;const&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; *tileData, &lt;b&gt;int&lt;/b&gt; tileSize, &lt;b&gt;const&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; *mapData, &lt;b&gt;int&lt;/b&gt; mapSize, &lt;b&gt;const&lt;/b&gt; &lt;b&gt;void&lt;/b&gt; *paletteData, &lt;b&gt;int&lt;/b&gt; paletteSize);&lt;br /&gt;&lt;br /&gt;#&lt;u&gt;endif&lt;/u&gt;&lt;/nds.h&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-1371826255757231667?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/1371826255757231667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/1371826255757231667'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/02/workshop-c-ii.html' title='workshop C II'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-5223471373622377548</id><published>2009-01-23T07:22:00.000-08:00</published><updated>2009-02-15T05:55:03.104-08:00</updated><title type='text'>Introducing nds: workshop 1</title><content type='html'>&lt;span style="font-family:arial;"&gt;Workshop 1: (draft version)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   1. What is nds?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   2. Installing the emulator and playing nds programs&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   3. Installing IDE, and other development tools (DevkitPro, Grit, Sox)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   4. Basic C (variabels, types, iterations, selections, array's, includes)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   5. Make your first program (what about....Hello World?)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;1. discovering the console nds&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;it has two screens!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;it has so many buttons&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;it has a touch screen&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;it has a 3D mode&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;it has two processors! But these two processors are not the same.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;you can program it yourself!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;how to get a program on the nds&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;2.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Nocash GBA Emulator&lt;/span&gt;: NO$GBA.EXE&lt;br /&gt;&lt;span style="font-family:arial;"&gt;*most reliable&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;NDeSmuME&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;*first notions discovering the memory: viewing maps, registers, (dont understand this now :-)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;3.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Installing the DevkitPro, working with Programmer's NotePad, Wingrit, grit and Sox.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;4. A first bite of C. Is it like JAVA?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;variables&lt;/span&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The memory of the nds is limited, so try using as small variables as possible&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;(even smaller variables will be introduced later :-)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;char, of type character 8 bits&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;short, int, long, of type integer 16/32 bits&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;double, float of type real 32/64 bits&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;then you have signed and unsigned:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;short -32,768 to 32,767&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;unsigned short 0 to 65,535,  the thing is simply shifted&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;declarations&lt;/span&gt;: you have to declare variables before using them&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int start, time1, time2;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;special numbers can be defined like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;#define PI 3.141592654&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:arial;" &gt;Arrays (actually pointers, but about pointers later)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int myarray[10];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;unsigned int list[5] = { 10, 15, 12, 19, 23 }; //giving the elements right away!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;float rdata[128], grid[5][5];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;the first element is  myArray[0];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;asking an element of an array: a = myArray[3];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;there is no boundery checking, because an array is a pointer to a position in memory.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;What a pointer is: later&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;when you declare an array the elements are not initialized.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;a loop with an array:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;for( i = 0; i &lt;= 127; i = i + 1 )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;      printf ( "\f\n", rdata[i] );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;   }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;what is wrong?&lt;/span&gt; Yep!&lt;br /&gt;&lt;span style="font-family:arial;"&gt;you forgot this:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;int i;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;dynamically declaring an array:&lt;br /&gt;&lt;pre class="source-c"&gt;&lt;span class="kw4"&gt;int&lt;/span&gt; *myArray; // don't know exactly how big it will be....&lt;br /&gt;//do a lot of stuff here....&lt;br /&gt;myArray = malloc&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="nu0"&gt;10&lt;/span&gt;*&lt;span class="kw4"&gt;sizeof&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw4"&gt;int&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;be careful to free the memory again:&lt;br /&gt;free&lt;span class="br0"&gt;(&lt;/span&gt; myArray )&lt;span class="br0"&gt;; //when aloc then free&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;while loop&lt;/span&gt;:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;while (  i &lt;= 100 )    /* loop until i &gt; 100 */&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;       printf ( "the number %i  \n ", i );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;       i++;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;structure of a well known C program:&lt;/span&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;table style="width: 351px; height: 156px;" border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;span style="font-family:arial;"&gt;#include &lt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;void main()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    printf("\nHello World\n");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;conditionals&lt;/span&gt;:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;if(i &lt;&gt;&lt;/span&gt;88)&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;i=88;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;if ( i ==88)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;printf("\n88\n");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;the &lt;span style="font-weight: bold;"&gt;switch &lt;/span&gt;is &lt;/span&gt;&lt;span style="font-family:arial;"&gt;sometimes &lt;/span&gt;&lt;span style="font-family:arial;"&gt;handy:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;switch (i)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;case 1:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;printf("it was a one!");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;break;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;case 2:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;printf("it was a two");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;break;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;default:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;...block of statements..&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;5.&lt;/span&gt;&lt;br /&gt;look closer at small example programs in the DevkitPro example folder, running on the emulator, practice some C, using the printing of characters on the upper or lower screen, switching between the screens:&lt;br /&gt;&lt;br /&gt;C programming: make the order like this:&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;table style="width: 351px; height: 298px;" border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;void setup()&lt;br /&gt;{&lt;br /&gt;//prepare your stuff&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void loop()&lt;br /&gt;{&lt;br /&gt;//do something a lot of times&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;setup();&lt;br /&gt;loop();&lt;br /&gt;}&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;The problem with every programming is not only the language but also the special effects.....special methods written for this language to serve the purpose faster...more comfortable sometimes, but these methods have to be learnt too....like for instance consoleInit&lt;br /&gt;&lt;br /&gt;assignment 1: now restructure the HelloWorld example in the examples of DevkitPro like this setup-loop scheme.&lt;br /&gt;&lt;br /&gt;assignment 2:make the printBothscreens like this setup-loop scheme (this will be more difficult because the consoleInit is rather  specialized, be careful!)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;have fun!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-5223471373622377548?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/5223471373622377548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/5223471373622377548'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/01/introducing-nds-workshop-1.html' title='Introducing nds: workshop 1'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-3147631493204079258</id><published>2009-01-17T04:04:00.001-08:00</published><updated>2011-01-10T07:07:21.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NSNumber'/><category scheme='http://www.blogger.com/atom/ns#' term='UIScrollView'/><category scheme='http://www.blogger.com/atom/ns#' term='int'/><category scheme='http://www.blogger.com/atom/ns#' term='CGContextShowTextAtPoint'/><category scheme='http://www.blogger.com/atom/ns#' term='NSString'/><title type='text'>Xcode Iphone Quickies</title><content type='html'>&lt;span style="font-size: 85%;"&gt;&lt;span style="font-family: arial;"&gt;found some quickies for meself :-)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;making an int from NSNumber:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;int myInt = (int)[(NSNumber *)numberObject intValue];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;also floatValue&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;making NSNumber from int:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: Times; font-size: 85%;"&gt;NSNumber *mynumberObj = [NSNumber numberWithInt:&lt;/span&gt;&lt;span style="font-size: 85%;"&gt;&lt;span style="font-family: arial;"&gt; 255]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;making a String from int:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;NSString *myString = [NSString stringWithFormat:@"%d", myInt];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;making an int from a String:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;int myInt = [mySTring intValue];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;concatenating two strings:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;NSString *myString1 =  [@"field" stringByAppendingString: myString1];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;than a useful blog showing how to draw on a view in all details, lines, text, an image&lt;/span&gt;&lt;br /&gt;&lt;a href="http://trailsinthesand.com/exploring-iphone-graphics-part-1/" style="font-family: arial;"&gt;http://trailsinthesand.com/exploring-iphone-graphics-part-1/&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;(you have to mirror the text, for instance....text is drawn in reverse in default.)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;while drawing like an artist you might run out of space, then you need the UIScrollView, this is a bit .... peculiar too: it seems you have to trick the interfacebuilder in believing the wrong things: first connecting the outlets, then changing the File's Owner to UISCrollView and it shows "errors" with the former outlets, while they work fine (?) Anyway here is a good tuto:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://blog.atrexis.com/index.cfm/2008/9/29/Interface-Builder-Tutorial" style="font-family: arial;"&gt;http://blog.atrexis.com/index.cfm/2008/9/29/Interface-Builder-Tutorial&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-3147631493204079258?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3147631493204079258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3147631493204079258'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/01/xcode-iphone-quickies.html' title='Xcode Iphone Quickies'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-3765579442661401002</id><published>2009-01-13T22:37:00.000-08:00</published><updated>2009-01-17T02:14:52.807-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='array'/><category scheme='http://www.blogger.com/atom/ns#' term='reading file'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><title type='text'>minigolf on the iphone</title><content type='html'>We started a minigolf on the nds, learning a lot about the way C uses arrays. The same process started with Xcode-Objective C on the Iphone, recreating this minigolf game.&lt;br /&gt;&lt;br /&gt;The minigolf has a small engine allowing for shapes of the field which are queer, not rectangular.&lt;br /&gt;For this we needed to triangulate the field and have arrays ready of the points, the lines and the triangles involved. The triangle class has an pointarray inside, as well as the three lines in an array.&lt;br /&gt;&lt;br /&gt;In the nds code, then the arrays were initialized like:&lt;br /&gt;&lt;br /&gt;u16 p3[]     = { 61,180,    22,171,    8,102,    8,42,    55,7,    95,13,    105,34,    136,69,    156,84,    164,83,    184,79,    188,74,    183,56,    179,52,    157,45,    151,45,    117,82,    114,87,    119,111,    120,115,    162,147,    160,166,    133,180,    84,144,    76,109,    76,79,    131,9,    196,6,    241,46,    237,74,    220,102,    198,125,    163,133,    127,103,    120,88,    84,53,    77,54,    64,66,    61,74,    60,132,    63,138,    86,166,     0,0,0,0,0};&lt;br /&gt;&lt;br /&gt;each three integers were a triangle, the naughts at the end were to stop the making triangle objects, C having no way of telling how long an array is (?).&lt;br /&gt;&lt;br /&gt;of course these data should be read in from an external file, so giving the possibility to add fields of your own. In Xcode i decided to do that immediately:&lt;br /&gt;&lt;br /&gt;reading in a .txt file: (The triangles are given only with the number of the points from a point array, so 1,2,3 means triangle with point number 1, point number 2, point number 3.)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;NSString *filePath2 = [[NSBundle mainBundle] pathForResource:@"triangles1" ofType:@"txt"];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        if (filePath2) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            NSString *myText = [NSString stringWithContentsOfFile:filePath2];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            if (myText) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                NSLog(myText); //see if it worked!&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                NSArray *arr = [myText componentsSeparatedByString:@","];&lt;br /&gt; &lt;/span&gt;&lt;br /&gt;and at the end separating the file with the comma's in between the numbers.&lt;br /&gt;Then the points were searched from the point array made earlier.&lt;br /&gt;&lt;br /&gt;ok before this code: don't forget to inilialize the array:&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;triangleArray = [[NSMutableArray alloc] init]; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;now use a loop to generate the set of three points:&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;integer_t i;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                for(i=0;i&lt;arr.count&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                    int triangleNumber1 = (int)[[arr objectAtIndex:i] intValue ];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                    int triangleNumber2 = (int)[[arr objectAtIndex:i+1] intValue ];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                    int triangleNumber3 = (int)[[arr objectAtIndex:i+2] intValue ];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;make the triangle object: (using the point array made earlier in the same way)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Triangle *myTriangle = [[Triangle alloc] initWithNumbers3:( MyPoint *)[pointArray objectAtIndex:triangleNumber1]:( MyPoint *)[pointArray objectAtIndex:triangleNumber2]:( MyPoint *)[pointArray objectAtIndex:triangleNumber3] ];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and adding this triangle object to the triangleArray:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                [triangleArray addObject:myTriangle ];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                NSLog(@"made triangleArray"); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        else&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            NSLog(@"no path found"); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;of course without the actual point, line and triangles classes you cannot do much with this code, but is sketches the principle. (This blog is a diairy.....what is written in 5 minutes....could have costed me a few houres, mainly searching for the right syntax in a for me "new" language, in all kinds of blogs on the web.)&lt;br /&gt;&lt;br /&gt;reference link array:&lt;br /&gt;&lt;a href="http://www.cocoadev.com/index.pl?NSMutableArray"&gt;http://www.cocoadev.com/index.pl?NSMutableArray&lt;/a&gt;&lt;br /&gt;reference link reading in an external file (scroll down):&lt;br /&gt;&lt;a href="http://iphoneincubator.com/blog/page/2"&gt;http://iphoneincubator.com/blog/page/2&lt;/a&gt;&lt;br /&gt;reference link for NSString "Quickies"&lt;br /&gt;&lt;a href="http://www.borkware.com/quickies/one?topic=NSString"&gt;http://www.borkware.com/quickies/one?topic=NSString&lt;/a&gt;&lt;br /&gt;&lt;/arr.count&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-3765579442661401002?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3765579442661401002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3765579442661401002'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/01/minigolf-on-iphone.html' title='minigolf on the iphone'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-9192822387358448713</id><published>2009-01-11T08:07:00.000-08:00</published><updated>2009-01-11T09:31:36.933-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='array'/><category scheme='http://www.blogger.com/atom/ns#' term='multiple view'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><category scheme='http://www.blogger.com/atom/ns#' term='subview'/><title type='text'>Iphone and multiple (sub) views</title><content type='html'>After quite a few tutorials and a first go at the minigolf game for the iphone (started at the nds - not yet finished :-) I asked myself if it was possible to combine more views. This could facilitate the game and is great for overlaying drawing.&lt;br /&gt;&lt;br /&gt;At first i searched and found an example of a rounded corner view here:&lt;br /&gt;&lt;a href="http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html"&gt;http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html&lt;/a&gt;&lt;br /&gt;but i didn't succeed in implementing this in my proto minigolf.&lt;br /&gt;&lt;br /&gt;Eventually i decided to try with a new clean project Viewbased.&lt;br /&gt;I added three views in the folder classes&lt;br /&gt;then i went to the interfacebuilder and took the ViewTestController.xib&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jq__kevBr8s/SWock6iGtbI/AAAAAAAABOQ/Yj54ccCINRE/s1600-h/Image+2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 206px; height: 320px;" src="http://2.bp.blogspot.com/_Jq__kevBr8s/SWock6iGtbI/AAAAAAAABOQ/Yj54ccCINRE/s320/Image+2.jpg" alt="" id="BLOGGER_PHOTO_ID_5290072132813239730" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I loaded this nib with 3 different views in the main view (see image) i then connected the type of the three subviews to my newly added classes, i colored the classes differently.&lt;br /&gt;saved the file, returned to Xcode and compiled,&lt;br /&gt;to my surprise this really simple procedure was accepted.&lt;br /&gt;The roundedrect view showed up as predicted with rounded rects.&lt;br /&gt;(In fact this is like overlaying ImageViews.)&lt;br /&gt;&lt;br /&gt;My mistake was combining interfacebuilder with programmed views, and adding these views in the&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;/*&lt;/span&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;// Implement loadView to create a view hierarchy programmatically, without using a nib.&lt;/span&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;- (void)loadView {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;*/&lt;/span&gt;&lt;br /&gt;function, because it said to do so "to create a view hierarchy programmatically", which i apparently misunderstood.&lt;br /&gt;&lt;br /&gt;I added in the rounded rect view a pentagon with this code:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; CGContextRef context = UIGraphicsGetCurrentContext();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; CGContextSetStrokeColorWithColor(context, [UIColor greenColor].CGColor);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;CGContextSetLineWidth(context, 5.0);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;CGPoint five[6];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    integer_t i;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    &lt;/span&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;    for(i=0;i&lt;6;i++)&lt;/span&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        five[i].x = 100 + 30* sin( i*2*3.1415/5);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        five[i].y = 100 + 30* cos( i*2*3.1415/5);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;NSLog(@"myPoint 4 #%f #%f", five[i].x, five[i].y);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;CGContextAddLines ( context, five, 6 );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    CGContextStrokePath(context);    &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;[When adding an UIImageView to one of the SubViews, the image when to big spills over the view. Just set the Clip Subview check to keep the image in bounds.&lt;br /&gt;&lt;br /&gt;Could it be possible to make this too big image scrolling? Certainly! But since i have three views inside a view it is a bit more complicated than the example here:&lt;br /&gt;&lt;a href="http://www.vimeo.com/1642150"&gt;http://www.vimeo.com/16421&lt;/a&gt;&lt;a href="http://www.vimeo.com/1642150"&gt;50&lt;/a&gt;&lt;br /&gt;(There must be a natural way. like the three views?) ]&lt;br /&gt;&lt;br /&gt;from which i learned that the array CGPoint five[6] can be made without the need of a MSMutableArray, meant for NSObjects. It is like ordinary C here for once.&lt;br /&gt;&lt;br /&gt;So slowly my C knowledge is becoming related to objective-C of Xcode&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SWock3NbJ6I/AAAAAAAABOI/Q-d5vbQ8cTk/s1600-h/Image+3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 170px; height: 320px;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SWock3NbJ6I/AAAAAAAABOI/Q-d5vbQ8cTk/s320/Image+3.jpg" alt="" id="BLOGGER_PHOTO_ID_5290072131921192866" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-9192822387358448713?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/9192822387358448713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/9192822387358448713'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/01/iphone-and-multiple-sub-views.html' title='Iphone and multiple (sub) views'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Jq__kevBr8s/SWock6iGtbI/AAAAAAAABOQ/Yj54ccCINRE/s72-c/Image+2.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-9024795585635963774</id><published>2009-01-07T06:23:00.000-08:00</published><updated>2009-07-14T21:21:14.297-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Objective-C'/><category scheme='http://www.blogger.com/atom/ns#' term='jailbreaking'/><category scheme='http://www.blogger.com/atom/ns#' term='emulator'/><category scheme='http://www.blogger.com/atom/ns#' term='Interfacebuilder'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><title type='text'>Iphone programming</title><content type='html'>Or is this called scripting? :-)&lt;br /&gt;&lt;br /&gt;I started with Xcode and Iphone programming quite naively thinking my C experience on the nds would help me out. Not at all! Xcode's Objective-C is quite different. Luckily there are a few tutorials around (they are everywhere - everyone seems to make about 10 a day). Following a tutorial is great, eventually it works, but you have no clue why. Idem for the interfacebuilder.&lt;br /&gt;SO in the end only doing it yourself helps and then it becomes clear that the tutorials only give you the most simple situations.&lt;br /&gt;Anyway some tuto's were helpful, here a few links to them:&lt;br /&gt;&lt;br /&gt;The first step:&lt;br /&gt;get to know the apple tutorials! These are the best found on the apple iphone dev site:&lt;br /&gt;&lt;a href="http://developer.apple.com/iphone/"&gt;http://developer.apple.com/iphone/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;lots of other tutorials can be found, for instance:&lt;br /&gt;&lt;a href="http://icodeblog.com/2008/10/20/iphone-programming-tutorial-using-uitouch-to-drag-an-image-around-the-screen/"&gt;http://icodeblog.com/2008/10/20/iphone-programming-tutorial-using-uitouch-to-drag-an-image-around-the-screen/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.bit-101.com/blog/?p=1784"&gt;http://www.bit-101.com/blog/?p=1784&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.iphonesdkarticles.com/2008/07/first-iphone-application.html"&gt;http://www.iphonesdkarticles.com/2008/07/first-iphone-application.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.appsamuck.com/" target="_blank"&gt;http://www.appsamuck.com&lt;/a&gt;&lt;br /&gt;but i think, with hindsight that the apple examples are just the best.&lt;br /&gt;&lt;br /&gt;following these tutorials is ok, but learning to work with the interface builder cannot be achieved this easy. For understanding the interface builder you could try these links:&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Interface_Builder"&gt;http://en.wikipedia.org/wiki/Interface_Builder&lt;/a&gt;&lt;br /&gt;&lt;a href="http://developer.apple.com/tools/interfacebuilder.html"&gt;http://developer.apple.com/tools/interfacebuilder.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Then comes the moment that you start making your own classes. Objective C has a curious way to declare the variables, properties, and call functions with mutiple variables...&lt;br /&gt;a few links can facilitate the process of getting used to Objective C:&lt;br /&gt;&lt;a href="http://cocoadevcentral.com/d/learn_objectivec/"&gt;http://cocoadevcentral.com/d/learn_objectivec/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.otierney.net/objective-c.html"&gt;http://www.otierney.net/objective-c.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Objective-C"&gt;http://en.wikipedia.org/wiki/Objective-C&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;also arrays are used different from normal C, be careful!&lt;br /&gt;&lt;br /&gt;The emulator of the iphone is very handy, because uploading to your iphone is quite an effeort with certificates and signatures (after paying the fee for becoming a developer)&lt;br /&gt;Turning the emulator is easy with Command LEFT or RIGHT.&lt;br /&gt;&lt;br /&gt;Uploading an application can be done, having the certificates and codes and signatures.&lt;br /&gt;But jailbreaking or hacking is seems also possible. I tried but my MacBook is just the only MAC machine which refuses this apparently.&lt;br /&gt;&lt;a href="http://www.iclarified.com/entry/index.php?enid=1881"&gt;http://www.iclarified.com/entry/index.php?enid=1881&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.hackthatphone.com/114/iphone_step2_mac.html"&gt;http://www.hackthatphone.com/114/iphone_step2_mac.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-9024795585635963774?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/9024795585635963774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/9024795585635963774'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2009/01/iphone-programming.html' title='Iphone programming'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-606199913703843180</id><published>2008-12-20T01:41:00.000-08:00</published><updated>2008-12-26T21:36:05.783-08:00</updated><title type='text'>LIBFAT</title><content type='html'>When working with external files, using Cpp:&lt;br /&gt;&lt;a href="http://chishm.drunkencoders.com/libfat/"&gt;http://chishm.drunkencoders.com/libfat/&lt;/a&gt;&lt;br /&gt;mind the makefile modifications, where to put the .a file (in the libnds folder).....and so on.....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-606199913703843180?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/606199913703843180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/606199913703843180'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/12/libfat.html' title='LIBFAT'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-6698352660467285320</id><published>2008-10-17T06:03:00.000-07:00</published><updated>2008-10-17T06:46:02.178-07:00</updated><title type='text'>2DArt nds</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SPiW-QWnomI/AAAAAAAAA2g/i0-aRYBIjLo/s1600-h/2Dart.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SPiW-QWnomI/AAAAAAAAA2g/i0-aRYBIjLo/s320/2Dart.jpg" alt="" id="BLOGGER_PHOTO_ID_5258118561240949346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2Dart nds!&lt;br /&gt;&lt;br /&gt;can be found at:&lt;br /&gt;&lt;a href="http://dl.qj.net/2Dart-Nintendo-DS/pg/12/fid/24377/catid/221"&gt;http://dl.qj.net/2Dart-Nintendo-DS/pg/12/fid/24377/catid/221&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;it has been built without tiles nor sprites, it works totally drawing directly in the bitmaps&lt;br /&gt;this has several advantages: for instance the letters can be drawn much more freely then using tiles or sprites....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-6698352660467285320?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/6698352660467285320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/6698352660467285320'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/10/2dart-nds-can-be-found-at-httpdl.html' title='2DArt nds'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Jq__kevBr8s/SPiW-QWnomI/AAAAAAAAA2g/i0-aRYBIjLo/s72-c/2Dart.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-3350825136897300558</id><published>2008-10-06T02:58:00.000-07:00</published><updated>2008-10-06T03:16:08.972-07:00</updated><title type='text'>c programming</title><content type='html'>For the nds in DevkitPro we can program either in C or C++.&lt;br /&gt;&lt;br /&gt;Here are some references for things which are a bit different in C:&lt;br /&gt;&lt;a href="http://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays"&gt;http://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Also you have to be careful with strings, which actually don't exist in C.&lt;br /&gt;&lt;span id="a8"&gt;char c; &lt;/span&gt;&lt;br /&gt;&lt;span id="a10"&gt;char &lt;/span&gt;&lt;span id="a38"&gt;&lt;/span&gt;&lt;span id="a10"&gt;string[100]; &lt;/span&gt;//a string&lt;br /&gt;&lt;span class="table_2_cell_2"&gt;&lt;span style="color: rgb(128, 0, 0);font-family:Courier New;" &gt;char month1[ ]={‘j’,’a’,’n’,’u’,’a’,’r’,’y’}; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="table_2_cell_2"&gt;&lt;span style="color: rgb(128, 0, 0);font-family:Courier New;" &gt;char month1[]=”January”;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span id="a38"&gt;strcpy(mystring, "hello");//to initialize a string&lt;br /&gt;&lt;/span&gt;&lt;span class="table_2_cell_2"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(128, 0, 0);font-family:Courier New;" &gt;strcpy(string1,string2);//copying&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span id="a46"&gt;strcat(mystring,"hello");//got paste strings together&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="table_2_cell_2"&gt;Character string terminated by a null character ‘\0’. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;see for instance:&lt;br /&gt;&lt;a href="http://www.exforsys.com/tutorials/c-language/handling-of-character-strings-in-c.html"&gt;http://www.exforsys.com/tutorials/c-language/handling-of-character-strings-in-c.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;converting an int to a string, very basic:&lt;br /&gt;u16 strokes = 12;&lt;br /&gt;u8 s10 = (u8)(strokes/10);&lt;br /&gt;u8 s1 = (u8)(strokes - s10*10);&lt;br /&gt;&lt;br /&gt;char store[] =  { (char)(s10 + 48) ,  (char)(s1+48) , '\0'};&lt;br /&gt;&lt;br /&gt;mind the difference between " and '&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Arrays:&lt;/span&gt;&lt;br /&gt;See link on top of page.&lt;br /&gt;Char string[] is already an array.&lt;br /&gt;There is no evident way to get the size of an array, be careful, my trick was to put a zero at the end, and test for the zero.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Headers and Source files&lt;/span&gt;&lt;br /&gt;You can put all the methonds or functions in the header, but accumulating headers like this has put me into trouble, so separate the method and the headers.&lt;br /&gt;&lt;br /&gt;Don't forget to put at the top of the header file:&lt;br /&gt;#ifndef __headername_H_&lt;br /&gt;#define __headername_H_&lt;br /&gt;and close with&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;otherwise you get the compiler complaining about multiple definitions of methods&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-3350825136897300558?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3350825136897300558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3350825136897300558'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/10/c-programming.html' title='c programming'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-3164415909277201571</id><published>2008-10-02T10:13:00.000-07:00</published><updated>2008-10-02T12:56:29.752-07:00</updated><title type='text'>Text in Tiles</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;Liranuna used a 16x8 arrow. (see the former blog on double tiled backgrounds)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;Please try in the last example an 8x8 version, and your screen will be filled with garbage!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;(Use this for the gfx2gba: gfx2gba -t8 -c16 -D -P -St.bin arrowTile.bmp&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;and you get the .bin thing immediately)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;The arrow tile number 0 fills the screen, and that is why the first 8x8 has to be transparent, then the second 8x8 has the arrow. It still works with 8x8 tiles.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;This becomes clear making letters from the arrow, adding the ASCII sequence.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;You need some special character sets for this, ugly and all, an 8x8 Font.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;There are a few links for this:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial; color: rgb(0, 0, 0);" href="http://www.dspassme.com/programmers_guide/tutorial/using_tiles.html"&gt;http://www.dspassme.com/programmers_guide/tutorial/using_tiles.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;The most deep article is this:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial; color: rgb(0, 0, 0);" href="http://www.coranac.com/tonc/text/tte.htm#sec-bmp"&gt;http://www.coranac.com/tonc/text/tte.htm#sec-bmp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;In the former example you can (if they are available) ask for the letters simply like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;calculate position in array, and take place 1 of the image (the arrow or the characters)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;bg0Map[POS2IDX(7, 5)] = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;font-family:arial;" &gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt; | TILE_FLIP_Y | TILE_PALETTE(2);//color 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;calculate position in array, and take place 40 of the image (the arrow)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;bg0Map[POS2IDX(7, 5)] = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;font-family:arial;" &gt;40&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt; | TILE_FLIP_Y | TILE_PALETTE(2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:arial;" &gt;Since the image found in the TONC link gives the ASCII sequence, you can use the ascii value of the character:&lt;/span&gt;&lt;br /&gt;&lt;pre  style="color: rgb(0, 0, 0);font-family:arial;"&gt;&lt;span class="keywordtype"&gt;char&lt;/span&gt;* msg[] = {&lt;br /&gt;&lt;br /&gt;&lt;span class="stringliteral"&gt;"http://www.dspassme.com/"&lt;/span&gt;,&lt;br /&gt;&lt;span class="stringliteral"&gt;"            programmers_guide/"&lt;/span&gt;&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre  style="color: rgb(0, 0, 0);font-family:arial;"&gt;&lt;span class="comment"&gt;// Draw the message on the screen.&lt;/span&gt;&lt;br /&gt;&lt;span class="keywordflow"&gt;for&lt;/span&gt;(i = 0; i &lt; &lt;span class="keyword"&gt;sizeof&lt;/span&gt;(msg) / &lt;span class="keyword"&gt;sizeof&lt;/span&gt;(&lt;span class="keywordtype"&gt;char&lt;/span&gt;*); ++i) {&lt;br /&gt;&lt;span class="keywordflow"&gt;for&lt;/span&gt;(j = 0; msg[i][j] != &lt;span class="charliteral"&gt;'\0'&lt;/span&gt;; ++j) {&lt;br /&gt;sub_map[j + (i * 32)] = msg[i][j] - &lt;span class="charliteral"&gt;' '&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;(As can be seen from the dspassme link, but they dont give the whole image.)&lt;br /&gt;&lt;br /&gt;From this starting point you can build your own characterset.&lt;br /&gt;It all stays in tiles, and doesn't count on your sprites, which is quit handy because&lt;br /&gt;you don't have enough sprites, if you want all our characters be present too!&lt;br /&gt;&lt;br /&gt;So it seems like the default consoleInit, but it isn't.....we can modify!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jq__kevBr8s/SOUSWhegDXI/AAAAAAAAA1g/DFryGipW3u0/s1600-h/let.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_Jq__kevBr8s/SOUSWhegDXI/AAAAAAAAA1g/DFryGipW3u0/s320/let.jpg" alt="" id="BLOGGER_PHOTO_ID_5252624718550273394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There is one problem i encountered, the transparancy was wrong.&lt;br /&gt;(Then it covers the whole screen, except for the letters.)&lt;br /&gt;This was already the case with my sprites.&lt;br /&gt;See the next blog for solving this, or better understanding the photoshop problem.&lt;br /&gt;(It can be that new photoshops handle this without a problem, mine is old, 7.05 or so...:-)&lt;br /&gt;&lt;br /&gt;But we can now go on: a 8x16 font, being twice as high....hmmmm what will the tiles of 8x8 do????&lt;br /&gt;Well the letters are cut in half and displayed top first bottom after in the tiles, so we have&lt;br /&gt;to modify the ASCII formula:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int i,j = 0;&lt;br /&gt;for(i = 0; i &lt; sizeof(msg) / sizeof(char*); ++i) {&lt;br /&gt;   for(j = 0; msg[i][j] != '\0'; ++j) {&lt;br /&gt;     bg0Map[j + (2*i * 32)] = (msg[i][j] - ' ') | TILE_FLIP_NONE | TILE_PALETTE(0);&lt;br /&gt;   bg0Map[j + ((2*i + 1) * 32)] = ( offset + (msg[i][j] - ' ')) | TILE_FLIP_NONE | TILE_PALETTE(2);&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_Jq__kevBr8s/SOUiunwS63I/AAAAAAAAA1o/ZqpDebDKxIA/s320/let2.jpg" alt="" id="BLOGGER_PHOTO_ID_5252642724738427762" border="0" /&gt;&lt;span style="text-decoration: underline;"&gt;Code&lt;/span&gt;&lt;a href="http://www.contrechoc.com/nds/letters.zip"&gt; example, 8x16 characters, click on left or right &lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.contrechoc.com/nds/letters.zip"&gt;half of the screen to change the offset of the lower half of the tiles&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-3164415909277201571?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3164415909277201571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3164415909277201571'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/10/text-in-tiles.html' title='Text in Tiles'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Jq__kevBr8s/SOUSWhegDXI/AAAAAAAAA1g/DFryGipW3u0/s72-c/let.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-365963378350336377</id><published>2008-09-28T09:07:00.000-07:00</published><updated>2008-10-05T01:13:12.891-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='double background'/><category scheme='http://www.blogger.com/atom/ns#' term='registers'/><title type='text'>tiles and backgrounds</title><content type='html'>&lt;span style="font-family:arial;"&gt;Manipulating tiles, their palettes and backgrounds asks for insight in the memory organization...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The knowledge is scattered, in simple examples, unfinished tutorials and tables. Here an effort to put it all together.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Our goal: getting a tiled background and a bitmap together, the bitmap serving as a frame around a game like chess, or minesweeper....without mixing up the memory by overlapping.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Most of the times the examples (see devkitPro) are clear while so simple. But combining some ideas immediately shows the complexity of the memory mappings the videorams and the BG registers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The starting tile example is from Liranuna's blog: &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.liranuna.com/"&gt;(lesson 3 and 4)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;But we want to combine a bmp-background with the tiles, and we get into the trouble of mem overlapping, resulting in bad graphics.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Here a table and registers  from:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://www.dspassme.com/programmers_guide/tutorial/registers.html#bg0_cr"&gt;http://www.dspassme.com/programmers_guide/tutorial/registers.html#bg0_cr&lt;/a&gt;&lt;br /&gt;&lt;a class="anchor" name="bg0_cr_addrs"  style="font-family:arial;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;For the main screen:&lt;br /&gt;&lt;/span&gt;Background Tile/Map Addresses&lt;/a&gt;&lt;span style="font-family:arial;"&gt; Care must be taken in choosing the map and graphic addresses as they overlap. (Indeed!)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;table style="font-family: arial;" border="1" cellpadding="3" cellspacing="3"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;Address &lt;/td&gt;&lt;td&gt;Map Addresses &lt;/td&gt;&lt;td&gt;Graphic Addresses  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06000000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(0) &lt;/td&gt;&lt;td colspan="8"&gt;BG_TILE_RAM(0)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06000800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(1)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06001000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(2)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06001800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(3)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06002000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(4)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06002800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(5)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06003000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(6)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06003800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(7)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06004000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(8) &lt;/td&gt;&lt;td colspan="8"&gt;BG_TILE_RAM(1)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06004800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(9)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06005000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(10)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06005800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(11)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06006000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(12)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06006800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(13)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06007000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(14)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06007800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(15)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06008000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(16) &lt;/td&gt;&lt;td&gt;BG_TILE_RAM(2)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06008800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(17)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06009000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(18)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x06009800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(19)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600A000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(20)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600A800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(21)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600B000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(22)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600B800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(23)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600C000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(24) &lt;/td&gt;&lt;td&gt;BG_TILE_RAM(3)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600C800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(25)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600D000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(26)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600D800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(27)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600E000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(28)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600E800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(29)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600F000 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(30)  &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0x0600F800 &lt;/td&gt;&lt;td&gt;BG_MAP_RAM(31)  &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;h3 style="font-family: arial;"&gt;&lt;a class="anchor" name="display_cr"&gt; DISPLAY_CR (0x04000000)&lt;/a&gt;&lt;/h3&gt;  &lt;table style="font-family: arial;" border="1" cellpadding="3" cellspacing="3"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;31 &lt;/td&gt;&lt;td&gt;30 &lt;/td&gt;&lt;td&gt;29 &lt;/td&gt;&lt;td&gt;28  &lt;/td&gt;&lt;td&gt;27 &lt;/td&gt;&lt;td&gt;26 &lt;/td&gt;&lt;td&gt;25 &lt;/td&gt;&lt;td&gt;24  &lt;/td&gt;&lt;td&gt;23 &lt;/td&gt;&lt;td&gt;22 &lt;/td&gt;&lt;td&gt;21 &lt;/td&gt;&lt;td&gt;20  &lt;/td&gt;&lt;td&gt;19 &lt;/td&gt;&lt;td&gt;18 &lt;/td&gt;&lt;td&gt;17 &lt;/td&gt;&lt;td&gt;16   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;31 &lt;/td&gt;&lt;td&gt;BGExtPal&lt;/td&gt;&lt;td&gt;29 &lt;/td&gt;&lt;td&gt;28  &lt;/td&gt;&lt;td&gt;27 &lt;/td&gt;&lt;td&gt;26 &lt;/td&gt;&lt;td&gt;25 &lt;/td&gt;&lt;td&gt;24  &lt;/td&gt;&lt;td&gt;23 &lt;/td&gt;&lt;td&gt;22 &lt;/td&gt;&lt;td&gt;21 &lt;/td&gt;&lt;td&gt;20  &lt;/td&gt;&lt;td colspan="2"&gt;FBBank &lt;/td&gt;&lt;td colspan="2"&gt;ExtMode   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;15 &lt;/td&gt;&lt;td&gt;14 &lt;/td&gt;&lt;td&gt;13 &lt;/td&gt;&lt;td&gt;12  &lt;/td&gt;&lt;td&gt;11 &lt;/td&gt;&lt;td&gt;10 &lt;/td&gt;&lt;td&gt;9 &lt;/td&gt;&lt;td&gt;8  &lt;/td&gt;&lt;td&gt;7 &lt;/td&gt;&lt;td&gt;6 &lt;/td&gt;&lt;td&gt;5 &lt;/td&gt;&lt;td&gt;4  &lt;/td&gt;&lt;td&gt;3 &lt;/td&gt;&lt;td&gt;2 &lt;/td&gt;&lt;td&gt;1 &lt;/td&gt;&lt;td&gt;0   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SprWin&lt;/td&gt;&lt;td&gt;Win1&lt;/td&gt;&lt;td&gt;Win0&lt;/td&gt;&lt;td&gt;Obj &lt;/td&gt;&lt;td&gt;BG3 &lt;/td&gt;&lt;td&gt;BG2 &lt;/td&gt;&lt;td&gt;BG1 &lt;/td&gt;&lt;td&gt;BG0  &lt;/td&gt;&lt;td&gt;BlnkScr&lt;/td&gt;&lt;td&gt;U6 &lt;/td&gt;&lt;td&gt;OAMHorzBlank&lt;/td&gt;&lt;td&gt;ObjMapMode &lt;/td&gt;&lt;td&gt;3D &lt;/td&gt;&lt;td colspan="3"&gt;Mode   &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;h3 style="font-family: arial;"&gt;&lt;a class="anchor" name="bg0_cr"&gt; BG0_CR (0x04000008)&lt;/a&gt;&lt;/h3&gt;&lt;span style="font-family:arial;"&gt; This 16 bit register controls the features related to background #0 on the main display. To activate this register, this background must be enabled in the &lt;/span&gt;&lt;a style="font-family: arial;" class="el" href="http://www.dspassme.com/programmers_guide/tutorial/registers.html#display_cr"&gt;DISPLAY_CR (0x04000000)&lt;/a&gt;&lt;span style="font-family:arial;"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;table style="font-family: arial;" border="1" cellpadding="3" cellspacing="3"&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;15 &lt;/td&gt;&lt;td&gt;14 &lt;/td&gt;&lt;td&gt;13 &lt;/td&gt;&lt;td&gt;12  &lt;/td&gt;&lt;td&gt;11 &lt;/td&gt;&lt;td&gt;10 &lt;/td&gt;&lt;td&gt;9 &lt;/td&gt;&lt;td&gt;8  &lt;/td&gt;&lt;td&gt;7 &lt;/td&gt;&lt;td&gt;6 &lt;/td&gt;&lt;td&gt;5 &lt;/td&gt;&lt;td&gt;4  &lt;/td&gt;&lt;td&gt;3 &lt;/td&gt;&lt;td&gt;2 &lt;/td&gt;&lt;td&gt;1 &lt;/td&gt;&lt;td&gt;0   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt;Size &lt;/td&gt;&lt;td&gt;Wrap  &lt;/td&gt;&lt;td colspan="5"&gt;Map  &lt;/td&gt;&lt;td&gt;Color &lt;/td&gt;&lt;td&gt;Mosaic &lt;/td&gt;&lt;td colspan="4"&gt;Tile  &lt;/td&gt;&lt;td colspan="2"&gt;Pri   &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;So, in this example:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://www.dspassme.com/programmers_guide/tutorial/using_tiles.html#tile02"&gt;http://www.dspassme.com/programmers_guide/tutorial/using_tiles.html#tile02&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;for the main screen:&lt;/span&gt;&lt;br /&gt;&lt;pre style="font-family: arial;"&gt;POWER_CR = POWER_ALL_2D;&lt;br /&gt;&lt;br /&gt;vramSetBankA(VRAM_A_MAIN_BG);&lt;br /&gt;DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE;&lt;br /&gt;BG0_CR = BG_256_COLOR | BG_TILE_BASE(0) | BG_MAP_BASE(20);&lt;br /&gt;&lt;br /&gt;These last three lines form a chain, combining a memory location to the videoram&lt;br /&gt;tile base on 0 and map base on (a safe???) 20.&lt;br /&gt;&lt;br /&gt;In Liranuna's example, apparently the map is smaller and put in front:&lt;br /&gt;BG0_CR = BG_32x32 | BG_COLOR_16 | BG_MAP_BASE(0) | BG_TILE_BASE(1);&lt;br /&gt;the map first and the tiles behind it.&lt;br /&gt;&lt;br /&gt;Then we have to copy the tiles and palettes&lt;br /&gt;memcpy((void*)BG_TILE_RAM(1), arrowTile_bin, arrowTile_bin_size);&lt;br /&gt;u16* bg0Map = (u16*)BG_TILE_RAM(0);//making a pointer to the map we can calculate where to put tiles.&lt;br /&gt;&lt;br /&gt;Adding another background? A bitmap this time, two tile-bg's would be too much :-)&lt;br /&gt;vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000);&lt;br /&gt;&lt;br /&gt;and now&lt;br /&gt;either this going for 0x06010000&lt;br /&gt;BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(4)  ; //this is 0x06010000&lt;br /&gt;u16* backBuffer =  (u16*)(0x06000000 + 256 * 256 * 1 );&lt;br /&gt;&lt;br /&gt;or this aiming at 0x06020000&lt;br /&gt;BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(8)  ; //this is 0x06020000&lt;br /&gt;u16* backBuffer =  (u16*)(0x06000000 + 256 * 256 * 2 );&lt;br /&gt;&lt;br /&gt;is possible....&lt;br /&gt;&lt;br /&gt;BG3_XDX = 1 &lt;&lt; bg3_xdy =" 0;" bg3_ydx =" 0;" bg3_ydy =" 1" bg3_cx =" 0;" bg3_cy =" 0;" class="mw-headline"&gt;Map Entries&lt;br /&gt;from&lt;br /&gt;&lt;a href="http://dev-scene.com/NDS/Tutorials_Day_4"&gt;http://dev-scene.com/NDS/Tutorials_Day_4&lt;/a&gt;&lt;br /&gt;of course also this example is explaining the same procedure, only it gives the tiles as a matrix.&lt;br /&gt;(The last entry of this excelent tutorial.....)&lt;br /&gt;&lt;br /&gt;The complete main.c of lesson 3 of Liranuna, but with an extra background becomes:&lt;br /&gt;&lt;br /&gt;// Including libnds’ set of defines&lt;br /&gt;#include &lt;nds.h&gt;&lt;br /&gt;// Include basic memory functions&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt;&lt;br /&gt;// Including our converted graphics&lt;br /&gt;#include "arrowTile_bin.h"&lt;br /&gt;&lt;br /&gt;// Macro to translate 2D coord into 1D map array&lt;br /&gt;#define POS2IDX(x, y) (x + (y*32))&lt;br /&gt;&lt;br /&gt;// Set of defines for tile flipping&lt;br /&gt;#define TILE_FLIP_NONE (0 &lt;&lt; reg_powercnt =" POWER_ALL_2D;" display_cr =" MODE_5_2D" bg0_cr =" BG_32x32" vram_a_cr =" VRAM_ENABLE" bg0map =" (u16*)BG_TILE_RAM(0);" bg0map =" (u16*)BG_MAP_BASE(0);" bg3_cr =" BG_BMP16_256x256" backbuffer ="  (u16*)(0x06000000" bg3_cr =" BG_BMP16_256x256" backbuffer ="  (u16*)(0x06000000" bg3_xdx =" 1" bg3_xdy =" 0;" bg3_ydx =" 0;" bg3_ydy =" 1" bg3_cx =" 0;" bg3_cy =" 0;" colormask =" 0x1F;" iy =" 0;" ix =" 0;" iy =" 186;" ix =" 0;" iy =" 0;" ix =" 240;" iy =" 0;" ix =" 0;"&gt;&lt;/string.h&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jq__kevBr8s/SN_U0ytrLQI/AAAAAAAAA0o/g__dAjoRN8U/s1600-h/l1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_Jq__kevBr8s/SN_U0ytrLQI/AAAAAAAAA0o/g__dAjoRN8U/s320/l1.jpg" alt="" id="BLOGGER_PHOTO_ID_5251149693968919810" border="0" /&gt;&lt;/a&gt;which gives the tiles in a frame of red, located on another background layer&lt;br /&gt;&lt;br /&gt;Liranuna gives a lesson 4 exemple with two backgrounds.&lt;br /&gt;Very usefull.&lt;br /&gt;I redesigned the frame exemple above with the arrows and a tiled image background.&lt;br /&gt;Because the arrows are 16 colors and this tiled background 256 colors i had to shift&lt;br /&gt;the colors of the tiled background, using gfx2gba, shifting 64 = 4 x 16 colors.&lt;br /&gt;//gfx2gba -c256 -St.tls -t8 -St.tls -C64 -v0 -pback.pal -m back.bmp&lt;br /&gt;then loading also shifted:&lt;br /&gt;void *paletteBuffer =  (void *)&amp;amp;BG_PALETTE[64] ;&lt;br /&gt;(and dmaCopy(paletteData, paletteBuffer, paletteSize); of course)&lt;br /&gt;This is how the palette looks, with four 16 color palettes and behind it the colors of the tiled background:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SOJuTl9kDUI/AAAAAAAAA1I/9R9hnihz264/s1600-h/pal.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SOJuTl9kDUI/AAAAAAAAA1I/9R9hnihz264/s320/pal.jpg" alt="" id="BLOGGER_PHOTO_ID_5251881398354316610" border="0" /&gt;&lt;/a&gt;This is the 256 color map at 0x0610000, = BG_TILE_RAM(4), and map BG_MAP_RAM(1) = &lt;/nds.h&gt;0x06000800&lt;br /&gt;arrows at: BG_TILE_BASE(3) = 0x0600C000 , tiles and BG_MAP_BASE(0), map (see table above )&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jq__kevBr8s/SOMly-u5htI/AAAAAAAAA1Y/Al1n47Tq_YA/s1600-h/tilev.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_Jq__kevBr8s/SOMly-u5htI/AAAAAAAAA1Y/Al1n47Tq_YA/s320/tilev.jpg" alt="" id="BLOGGER_PHOTO_ID_5252083148207523538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;nds.h&gt;&lt;br /&gt;&lt;/nds.h&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SOMlT1fKYiI/AAAAAAAAA1Q/RowYz8g0OeA/s1600-h/tile.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SOMlT1fKYiI/AAAAAAAAA1Q/RowYz8g0OeA/s320/tile.jpg" alt="" id="BLOGGER_PHOTO_ID_5252082613149655586" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;nds.h&gt;&lt;br /&gt;These examples about background organization can be found here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.contrechoc.com/nds/lesson3.zip"&gt;Above example,using the Liranuna's arrows and adding a red frame&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.contrechoc.com/nds/lesson3a.zip"&gt;Second example, 2 tiled background 16/256 color (arrows and image) example&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you wonder why Liranuna used a 16x8 arrow in his example, read the following blog!&lt;br /&gt;&lt;/nds.h&gt;&lt;/pre&gt;PS, so this works for the main screen, but don't think that you can copy this frame right away to the sub screen. The subscreen mem is much smaller, as you can see further on, of course an image can be displayed, as can be text, even from your own 16x8 font, but the red frame poses more problems!&lt;br /&gt;&lt;br /&gt;Main backgrounds: 0x06000000 - 0x06400000&lt;br /&gt;Sub  backgrounds:   0x06020000 - 0x06021000 which is much smaller&lt;br /&gt;&lt;br /&gt;This is a useful link with all kinds of register definitions, and here you can see the differences between VRAM_A VRAM_C and for instance VRAM_B:&lt;br /&gt;&lt;a href="http://takuto.info/libnds/arm9/video_8h.html#3bce26742d17eb8c77cf7338089f3ccf7cb3c69e848e7b5f045e932ee1e41f94"&gt;&lt;br /&gt;http://takuto.info/libnds/arm9/video_8h.html#3bce26742d17eb8c77cf7338089f3ccf7cb3c69e848e7b5f045e932ee1e41f94&lt;/a&gt;&lt;br /&gt;&lt;pre style="font-family: arial;"&gt;So the frame drawing (in the example red) on a bitmap can be done on the MAIN in mode 5.&lt;br /&gt;double tile - backgrounds can be done, both on MAIN and SUB, in mode 0&lt;br /&gt;&lt;br /&gt;on the SUB drawing on a bitmap (the red frame example) does not seem to be possible, in mode 5?&lt;br /&gt;Yes, this is possible, but you can only use one background (apparently)&lt;br /&gt;&lt;br /&gt;This is the example:&lt;br /&gt;&lt;a href="http://www.contrechoc.com/nds/letters.zip"&gt;simple script to see drawing on both screen in mode 5&lt;/a&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-365963378350336377?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/365963378350336377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/365963378350336377'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/09/tiles-and-backgrounds.html' title='tiles and backgrounds'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Jq__kevBr8s/SN_U0ytrLQI/AAAAAAAAA0o/g__dAjoRN8U/s72-c/l1.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-2833378000827007315</id><published>2008-09-25T06:28:00.000-07:00</published><updated>2008-09-25T06:35:32.771-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scripts'/><title type='text'>Usefull scripts</title><content type='html'>&lt;span style="font-family: arial;"&gt;Programming around for the nds is fun.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Sometimes you need something like "how to test if a point is within a triangle".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Well you can start thinking yourself, which is not bad, but other people have done it before, and still other people have refined their methods, so sometimes it is nice to use these tested scripts and go on with the game.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;I found this site:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://gmlscripts.com/"&gt;http://gmlscripts.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;you have to rewrite the script in the language you are programming in, but that is easy :-)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;ok for my problem, the triangle and the point:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style="font-family: arial;"&gt;{&lt;/b&gt;&lt;br /&gt;    &lt;span style="font-family: arial;" class="keyw"&gt;var&lt;/span&gt;&lt;span style="font-family: arial;"&gt; x1, y1, x2, y2, x3, y3, x4, y4, a, b, c;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    x1 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[0];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    y1 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[1];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    x2 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[2];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    y2 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[3];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    x3 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[4];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    y3 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[5];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    x4 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[6];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    y4 = &lt;/span&gt;&lt;span style="font-family: arial;" class="gvar"&gt;argument&lt;/span&gt;&lt;span style="font-family: arial;"&gt;[7];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    a = (x1 - x4)*(y2 - y4) - (x2 - x4)*(y1 - y4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    b = (x2 - x4)*(y3 - y4) - (x3 - x4)*(y2 - y4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;    c = (x3 - x4)*(y1 - y4) - (x1 - x4)*(y3 - y4);&lt;/span&gt;&lt;br /&gt;    &lt;span style="font-family: arial;" class="keyw"&gt;return&lt;/span&gt;&lt;span style="font-family: arial;"&gt; (&lt;/span&gt;&lt;span style="font-family: arial;" class="func"&gt;sign&lt;/span&gt;&lt;span style="font-family: arial;"&gt;(a) == &lt;/span&gt;&lt;span style="font-family: arial;" class="func"&gt;sign&lt;/span&gt;&lt;span style="font-family: arial;"&gt;(b) &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style="font-family: arial;" class="func"&gt;sign&lt;/span&gt;&lt;span style="font-family: arial;"&gt;(b) == &lt;/span&gt;&lt;span style="font-family: arial;" class="func"&gt;sign&lt;/span&gt;&lt;span style="font-family: arial;"&gt;(c));&lt;/span&gt;&lt;br /&gt;&lt;b style="font-family: arial;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;span style="font-family: arial;"&gt;this method uses three line-equations in an elegant way and tests the side of the lines, then the hypothesis that if two pairs of signs are the same, then the third has to agree, very funny!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Some info on the math.h functions is also usefull, but can be found practically everywhere.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b style="font-family: arial;"&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-2833378000827007315?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2833378000827007315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2833378000827007315'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/09/usefull-scripts.html' title='Usefull scripts'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-87699172087903292</id><published>2008-09-19T07:18:00.000-07:00</published><updated>2008-09-23T12:50:01.221-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='triangulation'/><category scheme='http://www.blogger.com/atom/ns#' term='pinball'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>nds Pinball 1 lines and points</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SNO0_2hurGI/AAAAAAAAA0A/ilv4V6XNFKs/s1600-h/gooncity.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SNO0_2hurGI/AAAAAAAAA0A/ilv4V6XNFKs/s320/gooncity.jpg" alt="" id="BLOGGER_PHOTO_ID_5247736999878503522" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Just fun, this image seen at &lt;a href="http://www.gooncity.com/"&gt;www.gooncity.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We tried to make PINBALL on the nds. (or a minigolf, whatever takes a ball to bounce.)&lt;br /&gt;A good exercise to reduce calculations and use the most simple numbers, as few doubles as possible!&lt;br /&gt;The first algorithm is just a simple (naïve) reflection idea.&lt;br /&gt;The ball has a position and a speed, and every time we calculate we advance the ball with its speed. We see if the ball crosses a line, if so, calculate the reflection.&lt;br /&gt;&lt;br /&gt;We needed a point (2D) and a line struct.&lt;br /&gt;&lt;br /&gt;The POINT struct:&lt;br /&gt;&lt;pre&gt;&lt;b&gt;typedef&lt;/b&gt; &lt;b&gt;struct&lt;/b&gt; intPoint{&lt;br /&gt;&lt;b&gt;double&lt;/b&gt; x; //these members have to become int's to save space and calc's!)&lt;br /&gt;&lt;b&gt;double&lt;/b&gt; y;&lt;br /&gt;}POINT;&lt;br /&gt;&lt;br /&gt;with a few useful methods like:&lt;br /&gt;dot&lt;br /&gt;length&lt;br /&gt;distance&lt;br /&gt;checkPointBetween (just see if a point lies between two other points&lt;br /&gt;&lt;br /&gt;nice was to discover that the sqrt (of math.h) does not function under the devkitpro with structmembers,&lt;br /&gt;so we had to write our own sqrt algorithm (haha!). Found this:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;double&lt;/b&gt;  mySqrt (&lt;b&gt;double&lt;/b&gt; value)&lt;br /&gt;{&lt;br /&gt;&lt;b&gt;const&lt;/b&gt; &lt;b&gt;double&lt;/b&gt; tol = 0.000005; &lt;i&gt;// relative error tolerance&lt;/i&gt;&lt;br /&gt;&lt;b&gt;double&lt;/b&gt; oldval, newval;&lt;br /&gt;&lt;br /&gt;   oldval = value; &lt;i&gt;// take value as first approximation&lt;/i&gt;&lt;br /&gt;   newval = (oldval + value/oldval)/2;&lt;br /&gt;   &lt;b&gt;while&lt;/b&gt; (fabs((newval-oldval)/newval) &gt; tol)&lt;br /&gt;     {&lt;br /&gt;       oldval = newval;&lt;br /&gt;       newval = (oldval + value/oldval)/2;&lt;br /&gt;     }&lt;br /&gt;  &lt;b&gt;return&lt;/b&gt; newval;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;For the line:&lt;br /&gt;&lt;b&gt;typedef&lt;/b&gt; &lt;b&gt;struct&lt;/b&gt; Line{&lt;br /&gt;POINT p1;&lt;br /&gt;POINT p2;&lt;br /&gt;&lt;b&gt;double&lt;/b&gt; cx ;//these members have to become int's to save space and calc's!)&lt;br /&gt;&lt;b&gt;double&lt;/b&gt; cy ;&lt;br /&gt;&lt;b&gt;double&lt;/b&gt; cc ;&lt;br /&gt;}LINE;&lt;br /&gt;&lt;br /&gt;with methods like:&lt;br /&gt;reflection&lt;br /&gt;intersection&lt;br /&gt;projection&lt;br /&gt;(using only geometrical methods)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SNO77qm7UoI/AAAAAAAAA0I/rc3mmtrMH6E/s1600-h/pin1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SNO77qm7UoI/AAAAAAAAA0I/rc3mmtrMH6E/s320/pin1.jpg" alt="" id="BLOGGER_PHOTO_ID_5247744624540996226" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;All went well, (after a lot of debugging) but one can simple see that&lt;br /&gt;the ball can always escape if just colliding on the point between to lines of a side.&lt;br /&gt;&lt;br /&gt;Two escape route scenarios:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jq__kevBr8s/SNlF9Yv3r0I/AAAAAAAAA0Q/3NERxo4SCuo/s1600-h/esc1.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_Jq__kevBr8s/SNlF9Yv3r0I/AAAAAAAAA0Q/3NERxo4SCuo/s320/esc1.jpg" alt="" id="BLOGGER_PHOTO_ID_5249303761594593090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SNlF9jr5g4I/AAAAAAAAA0Y/FofBVRIxVkE/s1600-h/esc2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SNlF9jr5g4I/AAAAAAAAA0Y/FofBVRIxVkE/s320/esc2.jpg" alt="" id="BLOGGER_PHOTO_ID_5249303764530725762" border="0" /&gt;&lt;/a&gt;The solution might be to look after reflection if the line between the old ball position&lt;br /&gt;and the new ball position crosses a line. If so, reverse speed...&lt;br /&gt;&lt;br /&gt;But there is another way to tackle the problem, using triangles.&lt;br /&gt;The field is partitioned in triangles.&lt;br /&gt;The ball is always in a triangle, so only three lines to deal with.&lt;br /&gt;Calculate the dcrossing and determine if the side is closed or open. If open the ball goes to the new trangle, if closed we get a reflection.&lt;br /&gt;Only problem: it is too fast, (haha). Because only crossing points are calculated we have to restrain the ball to get an even movement.&lt;br /&gt;&lt;br /&gt;Screenshot from a Devcpp prog:(with a graphic window)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jq__kevBr8s/SNlIBdOZqKI/AAAAAAAAA0g/zIHA1Q-vziE/s1600-h/triangle.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_Jq__kevBr8s/SNlIBdOZqKI/AAAAAAAAA0g/zIHA1Q-vziE/s320/triangle.jpg" alt="" id="BLOGGER_PHOTO_ID_5249306030539122850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Problem: if the ball is moving right on a point. We have to reflect it back.&lt;br /&gt;&lt;br /&gt;Then we need a way to generate the triangle information.&lt;br /&gt;&lt;br /&gt;we found Delaunay triangulation, together with some nice JAVA progs:&lt;br /&gt;&lt;a href="http://www.cs.cornell.edu/Info/People/chew/Delaunay.html"&gt;http://www.cs.cornell.edu/Info/People/chew/Delaunay.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://goanna.cs.rmit.edu.au/%7Egl/research/comp_geom/delaunay/delaunay.html"&gt;http://goanna.cs.rmit.edu.au/~gl/research/comp_geom/delaunay/delaunay.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;to be continued&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-87699172087903292?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/87699172087903292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/87699172087903292'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/09/nds-pinball-1-lines-and-points.html' title='nds Pinball 1 lines and points'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Jq__kevBr8s/SNO0_2hurGI/AAAAAAAAA0A/ilv4V6XNFKs/s72-c/gooncity.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-3746434860782597755</id><published>2008-08-31T09:20:00.001-07:00</published><updated>2008-08-31T09:35:31.794-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iprintf'/><category scheme='http://www.blogger.com/atom/ns#' term='compile error'/><category scheme='http://www.blogger.com/atom/ns#' term='sin'/><title type='text'>Trying to describe a bug</title><content type='html'>Something does not compile.&lt;br /&gt;Most of the time, your own fault!&lt;br /&gt;&lt;br /&gt;Once in a lifetime: a bug in the language.&lt;br /&gt;Here is one:&lt;br /&gt;but how difficult to describe it, because it is a weird combination i used, probably did it the first time ever.....&lt;br /&gt;&lt;br /&gt;in C:&lt;br /&gt;&lt;br /&gt;first i made a struct, just a POINT, two struct members&lt;br /&gt;then declared a global instance of this struct&lt;br /&gt;then i tested the sin function with a number (hardcoded) like .787878788 inside iprinf&lt;br /&gt;then i tested the sin function with a structmember&lt;br /&gt;&lt;br /&gt;the code is totally stripped:&lt;br /&gt;&lt;br /&gt;&lt;table style="width: 476px; height: 399px;" border="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;#&lt;u&gt;include&lt;/u&gt; --the math lib--&lt;math.h&gt;&lt;/math.h&gt;&lt;/pre&gt;&lt;math.h&gt;//this can be in a header file&lt;br /&gt;typedef struct point{&lt;br /&gt; double x;&lt;br /&gt; double y;&lt;br /&gt;}POINT;&lt;br /&gt;&lt;br /&gt;//-------------------------&lt;br /&gt;&lt;br /&gt;//source file:&lt;br /&gt;//include header file&lt;br /&gt;&lt;br /&gt;POINT q1;&lt;br /&gt;//this global does not functions in combination with iprintf&lt;br /&gt;//without  iprintf no problem&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;&lt;br /&gt;q1.x = 0.78787878787878;&lt;br /&gt;q1.y = 0.686868686868686;&lt;br /&gt;&lt;br /&gt;iprintf("point  %d\n", (int) (  100*sin( 0.12345 )  ) ) ;&lt;br /&gt;iprintf("point  %d\n", (int) (  100*sin( q1.x )  ) ) ;&lt;br /&gt;//multiply by 100 because it should run on the nds, without floats&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/math.h&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;compile error!&lt;br /&gt;&lt;br /&gt;declare this struct instance locally: no compile error&lt;br /&gt;&lt;br /&gt;without the iprintf (global struct instance again): no compile error.&lt;br /&gt;programming sneaky: global POINT q, local pointer to q, then iprint and sin of this pointer:&lt;br /&gt;compile error!&lt;br /&gt;&lt;br /&gt;the same in Cpp: no compile error.&lt;br /&gt;&lt;br /&gt;ok tried everything, i agree: this is a strange case! But it seems to be real.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-3746434860782597755?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3746434860782597755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/3746434860782597755'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/08/trying-to-describe-bug.html' title='Trying to describe a bug'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-4665337524057075157</id><published>2008-08-28T04:34:00.000-07:00</published><updated>2008-09-01T00:46:32.377-07:00</updated><title type='text'>nds and structs in C</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);"&gt;Just an example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I want to do several things with points and lines, so i need a few structs:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;then this goes into a headerfile:&lt;/span&gt;&lt;br /&gt;&lt;pre style="color: rgb(0, 0, 0);"&gt;&lt;b&gt;typedef&lt;/b&gt; &lt;b&gt;struct&lt;/b&gt; point{&lt;br /&gt; &lt;b&gt;double&lt;/b&gt; x;&lt;br /&gt; &lt;b&gt;double&lt;/b&gt; y;&lt;br /&gt;}POINT;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;typedef&lt;/b&gt; &lt;b&gt;struct&lt;/b&gt; normalPoint {&lt;br /&gt;  &lt;b&gt;double&lt;/b&gt; px;&lt;br /&gt;  &lt;b&gt;double&lt;/b&gt; py;&lt;br /&gt;  &lt;b&gt;double&lt;/b&gt; pc;&lt;br /&gt;}NORMALPOINT;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;typedef&lt;/b&gt; &lt;b&gt;struct&lt;/b&gt; pointDouble {&lt;br /&gt;  &lt;b&gt;struct&lt;/b&gt; point p;&lt;br /&gt;  &lt;b&gt;double&lt;/b&gt; angle;&lt;br /&gt;}POINTDOUBLE;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;typedef&lt;/b&gt; &lt;b&gt;struct&lt;/b&gt; line{&lt;br /&gt; &lt;b&gt;struct&lt;/b&gt; point p1;&lt;br /&gt; &lt;b&gt;struct&lt;/b&gt; point p2;&lt;br /&gt; &lt;b&gt;struct&lt;/b&gt; normalPoint np;&lt;br /&gt; &lt;b&gt;double&lt;/b&gt; angle;&lt;br /&gt;}LINE;&lt;/pre&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;and in the source file i can declare like this:&lt;/span&gt;&lt;br /&gt;&lt;pre style="color: rgb(0, 0, 0);"&gt;&lt;b&gt;struct&lt;/b&gt; point q1;//or POINT q1 etc&lt;br /&gt;&lt;b&gt;struct&lt;/b&gt; point q2;&lt;br /&gt;&lt;b&gt;struct&lt;/b&gt; point newPoint ; &lt;i&gt;//used to get the reflectionPoint&lt;/i&gt;&lt;br /&gt;&lt;b&gt;struct&lt;/b&gt; point reflectPoint ; &lt;i&gt;//used to get the reflectionPoint&lt;/i&gt;&lt;br /&gt;&lt;b&gt;struct&lt;/b&gt; point speedPoint ; &lt;i&gt;//for the speed&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;struct&lt;/b&gt; line lineArray[10];&lt;br /&gt;&lt;b&gt;struct&lt;/b&gt; line firstLine;&lt;br /&gt;&lt;br /&gt;and use it:&lt;br /&gt;&lt;br /&gt;q1.x = 20.0;&lt;br /&gt;q1.y = 30.0;&lt;br /&gt;q2.x = 120.0;&lt;br /&gt;q2.y = 130.0;&lt;br /&gt;&lt;br /&gt;firstLine.p1 = q1;&lt;br /&gt;firstLine.p1 = q2;&lt;br /&gt;&lt;br /&gt;lineArray[0] = firstLine;&lt;br /&gt;&lt;br /&gt;then i tested the sin by printing it on the ds screen and ran into trouble!&lt;br /&gt;Bad trouble indeed! See next blog.&lt;br /&gt;&lt;br /&gt;But this has nothing to do with the structs...&lt;br /&gt;&lt;br /&gt;Good to know: ARM9 can work with doubles, ARM7 not!&lt;br /&gt;To see if the double works, on the nds screen you have to print it as an int, multiplied, (for instance) by 1000....&lt;br /&gt;iprintf(" test double %d", (int)(100*sin(.787878)));&lt;br /&gt;&lt;br /&gt;Difference between C and C++ structs (and classes): see&lt;br /&gt;&lt;a href="http://carcino.gen.nz/tech/cpp/struct_vs_class.php"&gt;http://carcino.gen.nz/tech/cpp/struct_vs_class.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-4665337524057075157?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4665337524057075157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4665337524057075157'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/08/nds-and-structs-in-c.html' title='nds and structs in C'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-8784939846608703088</id><published>2008-08-28T04:23:00.001-07:00</published><updated>2008-08-31T09:19:48.769-07:00</updated><title type='text'>Different!</title><content type='html'>&lt;span style="font-family: arial;"&gt;This is a brief recapitulation of the differences between "normal" programming and programming in the Dev-Kit pro, in C.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;The pictures -&gt;using gfx2gba see this blog, &lt;/span&gt;&lt;a style="font-family: arial;" href="http://nds-homebrew-hslleiden.blogspot.com/2008/05/nds-sprites.html"&gt;several entrees&lt;br /&gt;&lt;/a&gt;&lt;span style="font-family: arial;"&gt;The sounds -&gt; using Sox, see &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.double.co.nz/nintendo_ds/nds_develop4.html"&gt;http://www.double.co.nz/nintendo_ds/nds_develop4.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;from JAVA (or other higher languages) to C, common C errors: &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.drpaulcarter.com/cs/common-c-errors.php"&gt;http://www.drpaulcarter.com/cs/common-c-errors.php&lt;br /&gt;&lt;/a&gt;&lt;span style="font-family: arial;"&gt;-&gt; mind the doubles and the floats! special for the nds!!!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;-&gt; mind the sin, cos, abs, atan! Special for the nds!!! (ok, turns out to be a strange bug in iprintf)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;-&gt; mind the pointers , &lt;/span&gt;&lt;a style="font-family: arial;" href="http://boredzo.org/pointers/"&gt;http://boredzo.org/pointers/&lt;br /&gt;&lt;/a&gt;&lt;span style="font-family: arial;"&gt;-&gt; mind the structs &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.learn-programming.za.net/programming_c_learn09.html"&gt;http://www.learn-programming.za.net/programming_c_learn09.html&lt;br /&gt;&lt;/a&gt;&lt;span style="font-family: arial;"&gt;-&gt; mind the headers!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;-&gt; mind the order in which you introduce methods!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;then also because of C, well...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;the makefile&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;the bat file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;and nds pecularities:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;the IRQ&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;the videomodes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;sprites or double buffering&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;and debugging, having to build, having to download, putting the .nds file  in an emulator,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;and even that can be different from really trying your game on the nds itself!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Programming environment, not trivial either!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;For me there are two possibilities:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Shared Node by Peter van Vliet available for students from HSL Leiden.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Microsoft's Visual C++ Express, specially prepaired for the DevKit Pro.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-8784939846608703088?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8784939846608703088'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8784939846608703088'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/08/different.html' title='Different!'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-5978702355964834888</id><published>2008-07-08T06:18:00.000-07:00</published><updated>2008-07-21T10:53:03.702-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='application'/><category scheme='http://www.blogger.com/atom/ns#' term='homebrew'/><category scheme='http://www.blogger.com/atom/ns#' term='download'/><category scheme='http://www.blogger.com/atom/ns#' term='free'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>splendid homebrew</title><content type='html'>Under this title a few of my favorite homebrew products&lt;br /&gt;WOW! Great stuff guys!&lt;br /&gt;&lt;br /&gt;The physics engine: &lt;a href="http://pp.mnfu.com/"&gt;http://pp.mnfu.com/&lt;/a&gt;&lt;br /&gt;incredibly funny, must be even more fun with the DS motion&lt;br /&gt;you can search on other people's idea's on the web!&lt;br /&gt;&lt;br /&gt;Then there is DSChess: can be downloaded here: &lt;a href="http://www.vonloesch.de/dschess"&gt;http://www.vonloesch.de/dschess&lt;/a&gt;&lt;br /&gt;For this size of machine a very good chess player, you have to have experience to beat it and even then every move can be your last.&lt;br /&gt;Seen a few bugs though: i could castle my king while being checked!&lt;br /&gt;One time i could not castle although it was allowed.&lt;br /&gt;Maybe it could give up sometimes when totally lost?&lt;br /&gt;Minor inconveniences!!!&lt;br /&gt;&lt;br /&gt;I like the NitroTracker too: &lt;a href="http://nitrotracker.tobw.net/"&gt;http://nitrotracker.tobw.net/&lt;/a&gt;&lt;br /&gt;Music can be recorded, or voice and put in a timeline, so making a rithm. Even MIDI!&lt;br /&gt;&lt;br /&gt;there is more on MIDI and the ds here, &lt;a href="http://dsmidiwifi.tobw.net/index.php?cat_id=1"&gt;http://dsmidiwifi.tobw.net/index.php?cat_id=1&lt;/a&gt;&lt;br /&gt;but i could not get it wirking, probably my Firelink card (?)&lt;br /&gt;&lt;br /&gt;Then sometimes I use DSOrganize: &lt;a href="http://www.dragonminded.com/?loc=ndsdev/DSOrganize"&gt;http://www.dragonminded.com/?loc=ndsdev/DSOrganize&lt;/a&gt;&lt;br /&gt;very funny, i bought the webbrowser, but this prog has all installed! And even make sketches and save some notes.&lt;br /&gt;&lt;br /&gt;There is a lot more, some are working on my firelink, some don't.&lt;br /&gt;But indeed, with all these free progs around, and even source code! Who needs more?&lt;br /&gt;Thx homebrewers!&lt;br /&gt;&lt;br /&gt;I saw this page with nice games:&lt;a href="http://www.mrbass.org/nintendoDS/homebrew/"&gt;http://www.mrbass.org/nintendoDS/homebrew/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-5978702355964834888?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/5978702355964834888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/5978702355964834888'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/07/splendid-homebrew.html' title='splendid homebrew'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-7656133728998484961</id><published>2008-07-07T12:02:00.001-07:00</published><updated>2008-07-07T12:48:06.719-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='registers'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>registers</title><content type='html'>The registers are quite interesting, seen as a table.&lt;br /&gt;from all kind of sources these tables are collected:&lt;br /&gt;&lt;br /&gt;first here a list with registers and addresses can be found:&lt;br /&gt;&lt;a href="http://www.dspassme.com/programmers_guide/tutorial/registers.html"&gt;http://www.dspassme.com/programmers_guide/tutorial/registers.html&lt;/a&gt;&lt;br /&gt;in this page tables are given too, with explanations&lt;br /&gt;&lt;h3&gt;&lt;a class="anchor" name="display_cr"&gt; DISPLAY_CR (0x04000000)&lt;/a&gt;&lt;/h3&gt; &lt;table border="1" cellpadding="3" cellspacing="3"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;31 &lt;/td&gt;&lt;td&gt;30 &lt;/td&gt;&lt;td&gt;29 &lt;/td&gt;&lt;td&gt;28  &lt;/td&gt;&lt;td&gt;27 &lt;/td&gt;&lt;td&gt;26 &lt;/td&gt;&lt;td&gt;25 &lt;/td&gt;&lt;td&gt;24  &lt;/td&gt;&lt;td&gt;23 &lt;/td&gt;&lt;td&gt;22 &lt;/td&gt;&lt;td&gt;21 &lt;/td&gt;&lt;td&gt;20  &lt;/td&gt;&lt;td&gt;19 &lt;/td&gt;&lt;td&gt;18 &lt;/td&gt;&lt;td&gt;17 &lt;/td&gt;&lt;td&gt;16   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;31 &lt;/td&gt;&lt;td&gt;BGExtPal&lt;/td&gt;&lt;td&gt;29 &lt;/td&gt;&lt;td&gt;28  &lt;/td&gt;&lt;td&gt;27 &lt;/td&gt;&lt;td&gt;26 &lt;/td&gt;&lt;td&gt;25 &lt;/td&gt;&lt;td&gt;24  &lt;/td&gt;&lt;td&gt;23 &lt;/td&gt;&lt;td&gt;22 &lt;/td&gt;&lt;td&gt;21 &lt;/td&gt;&lt;td&gt;20  &lt;/td&gt;&lt;td colspan="2"&gt;FBBank &lt;/td&gt;&lt;td colspan="2"&gt;ExtMode   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;15 &lt;/td&gt;&lt;td&gt;14 &lt;/td&gt;&lt;td&gt;13 &lt;/td&gt;&lt;td&gt;12  &lt;/td&gt;&lt;td&gt;11 &lt;/td&gt;&lt;td&gt;10 &lt;/td&gt;&lt;td&gt;9 &lt;/td&gt;&lt;td&gt;8  &lt;/td&gt;&lt;td&gt;7 &lt;/td&gt;&lt;td&gt;6 &lt;/td&gt;&lt;td&gt;5 &lt;/td&gt;&lt;td&gt;4  &lt;/td&gt;&lt;td&gt;3 &lt;/td&gt;&lt;td&gt;2 &lt;/td&gt;&lt;td&gt;1 &lt;/td&gt;&lt;td&gt;0   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SprWin&lt;/td&gt;&lt;td&gt;Win1&lt;/td&gt;&lt;td&gt;Win0&lt;/td&gt;&lt;td&gt;Obj &lt;/td&gt;&lt;td&gt;BG3 &lt;/td&gt;&lt;td&gt;BG2 &lt;/td&gt;&lt;td&gt;BG1 &lt;/td&gt;&lt;td&gt;BG0  &lt;/td&gt;&lt;td&gt;BlnkScr&lt;/td&gt;&lt;td&gt;U6 &lt;/td&gt;&lt;td&gt;OAMHorzBlank&lt;/td&gt;&lt;td&gt;ObjMapMode &lt;/td&gt;&lt;td&gt;3D &lt;/td&gt;&lt;td colspan="3"&gt;Mode   &lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;//-------other sources------------------------------------------------------------------&lt;br /&gt;&lt;h3 style="font-weight: normal;" align="left"&gt;&lt;span style="font-size:100%;"&gt;BGx_CR:(background)&lt;/span&gt;&lt;/h3&gt;   &lt;table width="680" border="1"&gt;     &lt;tbody&gt;&lt;tr bg="" style="color: rgb(204, 204, 204);"&gt;        &lt;td style="color: rgb(0, 0, 0);" width="38"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b15&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="41"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b14&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="40"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b13&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="36"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b12&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="37"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b11&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="36"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b10&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="35"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b9&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="35"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b8&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="31"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b7&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="30"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b6&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="31"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b5&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="34"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b4&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="36"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b3&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="52"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b2&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="52"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b1&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="52"&gt;          &lt;div align="center"&gt;&lt;span style=";font-family:Arial,Helvetica,sans-serif;font-size:100%;"  &gt;b0&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;     &lt;tr&gt;        &lt;td style="color: rgb(0, 0, 0);" colspan="2"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Size&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="40"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Wrap&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" colspan="5"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Map Block Num&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="31"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Color Mode&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="30"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Mosaic&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="31"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;.&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" width="34"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;.&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" colspan="2"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Tile Block Num&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;       &lt;td style="color: rgb(0, 0, 0);" colspan="2"&gt;          &lt;div align="center"&gt;&lt;span style="font-size:100%;"&gt;Priority&lt;/span&gt;&lt;/div&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;                  &lt;br /&gt;&lt;a href="http://edorul.ifrance.com/french/chapitre12.htm"&gt;http://edorul.ifrance.com/french/chapitre12.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;//-------------------------------------------------------------------------------------------&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;  &lt;h3 style="font-weight: normal;"&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt;Attribute&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt; :&lt;/span&gt;&lt;/span&gt;&lt;span lang="NO-BOK"&gt; 0 (sprite attribute)&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;table class="MsoNormalTable" style="border: medium none ; width: 100%; border-collapse: collapse; margin-left: 4.8pt; margin-right: 4.8pt;" width="100%" align="left" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.36%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;14&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;13&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.28%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;11&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;9&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;8&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;7&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.1%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td colspan="2" style="border-style: none solid solid; padding: 0cm 5.4pt; width: 12.62%;" valign="top" width="12%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;Shape&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;C&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 6.28%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;M&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td colspan="2" style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 12.5%;" valign="top" width="12%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;Alpha&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;SD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;R&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td colspan="8" style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 49.84%;" valign="top" width="49%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;Y&lt;/span&gt;&lt;span lang="NO-BOK"&gt;-coordinate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;a href="http://home.no/neogeo/HOVEDSIDE_INDEX/GBA_HOVEDSIDE_INDEX_ENGELSK/GBA%20HTML%20LEKSJONER%201-5/GBA_Lek4_english.htm"&gt;&lt;span lang="NO-BOK"&gt;&lt;o:p&gt;http://home.no/neogeo/HOVEDSIDE_INDEX/GBA_HOVEDSIDE_INDEX_ENGELSK/GBA%20HTML%20LEKSJONER%201-5/GBA_Lek4_english.htm&lt;/o:p&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang="NO-BOK"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt;Attribute&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt; :&lt;/span&gt;&lt;/span&gt;&lt;span lang="NO-BOK"&gt; 1&lt;/span&gt;&lt;span  lang="EN-GB" style="color:black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="border: medium none ; width: 101.58%; border-collapse: collapse; margin-left: 4.8pt; margin-right: 4.8pt;" width="100%" align="left" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;14&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.28%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;13&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.28%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;11&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;9&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;8&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;7&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.18%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td colspan="2" style="border-style: none solid solid; padding: 0cm 5.4pt; width: 12.46%;" valign="top" width="12%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;Form&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 6.28%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;VF&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 6.28%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;HF&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td colspan="3" style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 18.74%;" valign="top" width="18%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;Rot data index&lt;/span&gt;&lt;span lang="NO-BOK"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td colspan="9" style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 56.2%;" valign="top" width="56%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span lang="NO-BOK"&gt;X&lt;/span&gt;&lt;span lang="NO-BOK"&gt;-coordinate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;span lang="NO-BOK"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt;Attribute&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="GramE"&gt;&lt;span lang="NO-BOK"&gt; :&lt;/span&gt;&lt;/span&gt;&lt;span lang="NO-BOK"&gt; 2&lt;/span&gt;&lt;/p&gt;      &lt;table class="MsoNormalTable" style="border: medium none ; width: 101.24%; border-collapse: collapse;" width="100%" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;14&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;13&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;11&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;9&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;8&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;7&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.24%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.26%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; padding: 0cm 5.4pt; width: 6.2%;" valign="top" width="6%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td colspan="4" style="border-style: none solid solid; padding: 0cm 5.4pt; width: 24.98%;" valign="top" width="24%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;Palette nummer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td colspan="2" style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 12.52%;" valign="top" width="12%"&gt;   &lt;h2&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="text-decoration: none;" lang="NO-BOK"&gt;Priority&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;   &lt;/td&gt;   &lt;td colspan="10" style="border-style: none solid solid none; padding: 0cm 5.4pt; width: 62.52%;" valign="top" width="62%"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span  lang="NO-BOK" style="color:black;"&gt;Sprite number&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;span lang="NO-BOK"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//-------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;table style="width: 251px; height: 67px;" title="tbl-reg-mosaic" class="reg" id="tbl-reg-mosaic" border="1" cellpadding="4" cellspacing="0" frame="void"&gt; &lt;caption class="reg"&gt;   REG_MOSAIC @ &lt;code&gt;0400:004Ch&lt;/code&gt; &lt;/caption&gt; &lt;tbody&gt;&lt;tr class="bits"&gt;  &lt;td&gt;F E D C&lt;/td&gt;&lt;td&gt;B A 9 8 &lt;/td&gt;&lt;td&gt;7 6 5 4&lt;/td&gt;&lt;td&gt;3 2 1 0 &lt;/td&gt;&lt;/tr&gt;&lt;tr class="bf"&gt;  &lt;td class="rclr3"&gt;Ov  &lt;/td&gt;&lt;td class="rclr2"&gt;Oh  &lt;/td&gt;&lt;td class="rclr1"&gt;Bv  &lt;/td&gt;&lt;td class="rclr0"&gt;Bh&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;a href="http://www.coranac.com/tonc/text/gfx.htm#sec-mos"&gt;http://www.coranac.com/tonc/text/gfx.htm#sec-mos&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;//-------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;a class="anchor" name="display_cr"&gt; IRQ ( )&lt;/a&gt;&lt;/h3&gt; &lt;table border="1" cellpadding="3" cellspacing="3"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;24&lt;br /&gt;&lt;/td&gt;&lt;td&gt;23 &lt;/td&gt;&lt;td&gt;22&lt;br /&gt;&lt;/td&gt;&lt;td&gt;21&lt;br /&gt;&lt;/td&gt;&lt;td&gt;19 20&lt;br /&gt;&lt;/td&gt;&lt;td style="text-align: center;"&gt; 17 18 &lt;/td&gt;&lt;td&gt;18 &lt;/td&gt;&lt;td style="text-align: center;"&gt;16 &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_WIFI&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_SPI&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_LID&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_GEOMETRY_FIFO&lt;/span&gt;  &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_CARD&lt;/span&gt;&lt;br /&gt;&lt;span class="code"&gt;IRQ_CARD_LINE&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td colspan="2"&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_FIFO_EMPTY&lt;/span&gt;&lt;br /&gt;&lt;span class="code"&gt;IRQ_FIFO_NOT_EMPTY&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td colspan="1"&gt;&lt;pre class="fragment"&gt; &lt;a class="code" href="http://takuto.info/libnds/arm7j/interrupts_8h.html#e384b89225fb3517bba35d3dc790c716b6c94f7a619bdbcb0fc28eb937653892"&gt;IRQ_IPC_SYNC&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;   &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;14 &lt;/td&gt;&lt;td&gt;13 &lt;/td&gt;&lt;td&gt;12&lt;br /&gt;&lt;/td&gt;&lt;td&gt;11 10 9 8  &lt;/td&gt;&lt;td&gt;7 &lt;/td&gt;&lt;td&gt;6  5 4 3 &lt;/td&gt;&lt;td&gt;2 &lt;/td&gt;&lt;td&gt;1 &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_CART&lt;/span&gt;&lt;/pre&gt; &lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_KEYS&lt;/span&gt; &lt;/pre&gt; &lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_DMA0&lt;br /&gt;&lt;/span&gt;&lt;span class="code"&gt;IRQ_DMA1&lt;/span&gt;&lt;br /&gt;&lt;span class="code"&gt;IRQ_DMA2&lt;/span&gt;&lt;br /&gt;&lt;span class="code"&gt;IRQ_DMA3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_NETWORK&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;td&gt; &lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_TIMER0&lt;/span&gt;&lt;span class="code"&gt;&lt;br /&gt;IRQ_TIMER1&lt;br /&gt;&lt;/span&gt;&lt;span class="code"&gt;IRQ_TIMER2&lt;br /&gt;&lt;/span&gt;&lt;span class="code"&gt;IRQ_TIMER3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;/td&gt;&lt;td colspan="2"&gt;&lt;pre class="fragment"&gt;&lt;span class="code"&gt;IRQ_VBLANK&lt;/span&gt;&lt;br /&gt;&lt;span class="code"&gt;IRQ_&lt;/span&gt;&lt;span class="code"&gt;HBLANK&lt;/span&gt;&lt;br /&gt;&lt;span class="code"&gt;IRQ_VCOUNT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;a href="http://takuto.info/libnds/arm7j/interrupts_8h.html#e384b89225fb3517bba35d3dc790c71638af5b8afc08fd0c0423b74f1e944ff9"&gt;http://takuto.info/libnds/arm7j/interrupts_8h.html#e384b89225fb3517bba35d3dc790c71638af5b8afc08fd0c0423b74f1e944ff9&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-7656133728998484961?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7656133728998484961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7656133728998484961'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/07/registers.html' title='registers'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-5330438367210955675</id><published>2008-07-06T22:31:00.000-07:00</published><updated>2008-07-07T00:31:45.264-07:00</updated><title type='text'>pictures of games</title><content type='html'>Doing the technical stuff is one thing.&lt;br /&gt;Making pictures for the nds is another speciality.&lt;br /&gt;&lt;br /&gt;here a link with some examples (and not to much pub-noise):&lt;br /&gt;&lt;a href="http://www.dstouch.com/"&gt;http://www.dstouch.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.gamersunderground.net/ds/screens/"&gt;http://www.gamersunderground.net/ds/screens/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;to make these pictures you have to be a real designer, photoshopper, blender specialist!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-5330438367210955675?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/5330438367210955675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/5330438367210955675'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/07/pictures-of-games.html' title='pictures of games'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-6355346673502408455</id><published>2008-07-04T01:31:00.001-07:00</published><updated>2008-09-19T05:53:25.190-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='attributes'/><category scheme='http://www.blogger.com/atom/ns#' term='sprites'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>sprites attributes</title><content type='html'>Using the sprites engine all kinds of attributes can be set:&lt;br /&gt;&lt;br /&gt;most info can be found on the pages about the gba, the memory registers have stayed the same apparently.&lt;br /&gt;&lt;br /&gt;for instance the size:&lt;br /&gt;ATTR1_SIZE_8 --actually this is the tile size&lt;br /&gt;ATTR1_SIZE_16 available 64 sprites, when rotscale (ATTR0_ROTSCALE_DOUBLE)  is double, 32 when not double&lt;br /&gt;ATTR1_SIZE_32 16 sprites in rotscale is double, or 32,&lt;br /&gt;ATTR1_SIZE_64 4 sprites only, rotscale is double, or 8&lt;br /&gt;&lt;br /&gt;then there is the color palette: (watch the number behind ATTR)&lt;br /&gt;ATTR0_COLOR_256 one palette for all colors&lt;br /&gt;ATTR0_COLOR_16 different palettes for sprites possible&lt;br /&gt;&lt;br /&gt;it is possible to link a sprites (or more) to a rotation, before that you have to enable this:&lt;br /&gt;ATTR0_ROTSCALE&lt;br /&gt;ATTR0_ROTSCALE_DOUBLE the difference between these two is that ATTR0_ROTSCALE rotates the sprite inside the square it uses when not rotated. Double allows for full rotation. But the consequence is that the sprite is also shifted a sprite half to the right under corner. So coordinates must be revised when changing from ATTR0_ROTSCALE to ATTR0_ROTSCALE_DOUBLE. The ATTR0_ROTSCALE_DOUBLE seems to be the most logical choice, but you have less sprites. For instance for letters which will not be rotated, don't use ATTR0_ROTSCALE_DOUBLE.&lt;br /&gt;&lt;br /&gt;ATTR0_MOSAIC you can "pixelize" the tiles: an example (background and sprite)&lt;br /&gt;&lt;a href="http://www.coranac.com/tonc/text/gfx.htm#sec-mos"&gt;http://www.coranac.com/tonc/text/gfx.htm#sec-mos&lt;/a&gt;&lt;br /&gt;but the setting of the ATTR is not enough you have to give the size of the "big pixels"&lt;br /&gt;you have one possibility, one register for MOSAIC effects:&lt;br /&gt;REG_MOSAIC =  &lt;code&gt;0x0400 004Ch&lt;br /&gt;&lt;br /&gt;now you have to be aware of the peculiarities of registers:&lt;br /&gt;&lt;a href="http://dev-scene.com/NDS/Tutorials_Day_3#What_is_a_register"&gt;http://dev-scene.com/NDS/Tutorials_Day_3#What_is_a_register&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;the PA lib comes with a method to set the X and Y values of the mosaic attribute&lt;br /&gt;&lt;a href="http://www.aaronrogers.com/nintendods/PA_Lib/Day10_Mosaic/"&gt;http://www.aaronrogers.com/nintendods/PA_Lib/Day10_Mosaic/&lt;/a&gt;&lt;br /&gt;as usual in KODERS you can find the source of these functions&lt;br /&gt;&lt;a href="http://www.koders.com/c/fidC065D03E3601EFB57A73B083E0C080699B1F4741.aspx"&gt;http://www.koders.com/c/fidC065D03E3601EFB57A73B083E0C080699B1F4741.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;from all this comes the following to get the MOSAIC on sprites&lt;br /&gt;&lt;/code&gt;int h_size = 4;&lt;br /&gt;int v_size = 3;&lt;br /&gt;#define REG_MOSAIC_MAIN  (*(volatile unsigned int *) 0x0400004C)&lt;br /&gt;#define REG_MOSAIC_SUB  (*(volatile unsigned int *) 0x0400104C)&lt;br /&gt;REG_MOSAIC_MAIN &amp;amp;= (255 &lt;&lt;&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;useful links are coming from the gba:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.webbesen.dk/gba/sprites.asp"&gt;http://www.webbesen.dk/gba/sprites.asp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://home.no/neogeo/HOVEDSIDE_INDEX/GBA_HOVEDSIDE_INDEX_ENGELSK/GBA%20HTML%20LEKSJONER%201-5/GBA_Lek4_english.htm"&gt;http://home.no/neogeo/HOVEDSIDE_INDEX/GBA_HOVEDSIDE_INDEX_ENGELSK/GBA%20HTML%20LEKSJONER%201-5/GBA_Lek4_english.htm&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-6355346673502408455?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/6355346673502408455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/6355346673502408455'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/07/sprites-attributes.html' title='sprites attributes'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-2203396773313285277</id><published>2008-06-20T09:56:00.000-07:00</published><updated>2008-07-04T01:31:09.087-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='palette'/><category scheme='http://www.blogger.com/atom/ns#' term='color'/><category scheme='http://www.blogger.com/atom/ns#' term='sprite'/><category scheme='http://www.blogger.com/atom/ns#' term='tile'/><category scheme='http://www.blogger.com/atom/ns#' term='gfx2gba'/><title type='text'>sprites how to prepare</title><content type='html'>to prepare the 16 color palette and the tiles of a 16 x 64 (4 times 16x16) sprite use:&lt;br /&gt;gfx2gba -c16 -D -T16 -t8 -a0 -pgameSprites.pal -St.tls gameSprites.bmp&lt;br /&gt;&lt;br /&gt;gameSprites.bmp is saved with indexed colors and the number of colors is not over 16.&lt;br /&gt;&lt;br /&gt;the image is 16 pixels in height and n x 16 pixels in width (for several sprites of 16 x 16 )&lt;br /&gt;&lt;br /&gt;c16 means 16 colors if you want to use the 256 palette use c256&lt;br /&gt;T16 means the sprite is 16 wide&lt;br /&gt;t8 means the tiles of the sprites are 8 x 8&lt;br /&gt;a0 means the transparent color is the 0the color&lt;br /&gt;&lt;br /&gt;gives 2 files gameSprites.pal and gameSprites.tls&lt;br /&gt;64 sprites of 16x16&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;for 32 x 32 spites:&lt;/span&gt;&lt;br /&gt;wide images have to be well prepared: this simple sequence might be useful:&lt;br /&gt;0 32 64 96 128 160 192 234 256 288 320 352 384  416 448 480 --------- 512 544 576 608 640&lt;br /&gt;&lt;br /&gt;to prepare the palette and the tiles of a 16 x 64 (4 times 16x16) sprite use:&lt;br /&gt;gfx2gba -c16 -D -T32 -t8 -a0 -pgameSprites.pal -St.tls gameSprites.bmp&lt;br /&gt;&lt;br /&gt;T32 means the sprite is 32 wide&lt;br /&gt;&lt;br /&gt;only 16 sprites of 32 x 32 in a normal sprite setting&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;for 64 x 64 sprites:&lt;/span&gt;&lt;br /&gt;wide images have to be well prepared: this simple sequence might be useful:&lt;br /&gt;0 64 128 192 256 -------------320 384  448 512 576 640&lt;br /&gt;atlhough you can only put 4 of these big sprites in normal sprite mem!&lt;br /&gt;&lt;br /&gt;to prepare the palette and the tiles of a 16 x 64 (4 times 16x16) sprite use:&lt;br /&gt;gfx2gba -c16 -D -T64 -t8 -a0 -pgameSprites.pal -St.tls gameSprites.bmp&lt;br /&gt;&lt;br /&gt;T64 means the sprite is 64 wide&lt;br /&gt;&lt;br /&gt;only only only 4 sprites of 64 x 64 (unless extra mem is used)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-2203396773313285277?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2203396773313285277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2203396773313285277'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/06/sprites-how-to-prepare.html' title='sprites how to prepare'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-4932301127372529525</id><published>2008-06-09T08:25:00.000-07:00</published><updated>2008-06-18T09:52:28.713-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='angle'/><category scheme='http://www.blogger.com/atom/ns#' term='rotation'/><category scheme='http://www.blogger.com/atom/ns#' term='atan'/><category scheme='http://www.blogger.com/atom/ns#' term='sprite'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>nds and the atan</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SFk9OWmKvbI/AAAAAAAAAzs/DLaOWX_9zOs/s1600-h/atan.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SFk9OWmKvbI/AAAAAAAAAzs/DLaOWX_9zOs/s320/atan.jpg" alt="" id="BLOGGER_PHOTO_ID_5213265360451190194" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hm, I wanted to shoot an arrow, in the direction in which a sprite is dragged, using the touchscreen of course.&lt;br /&gt;So the arrow sprite has to be rotated, but we have the x distance and the y distance of the dragging.&lt;br /&gt;To get the angle, normally the atan or atan2 is used (this even workd in Second Life!!!)&lt;br /&gt;But apparently not in the nds world...&lt;br /&gt;atan gives an error..... not found in devkitpro???&lt;br /&gt;&lt;br /&gt;(ok i know there is no sin or cosin so this could be expected - look up tables is the magic word.)&lt;br /&gt;(where can i find the look-up tables of the atan?)&lt;br /&gt;&lt;br /&gt;i searched and found an interesting formula (approximation of the arctan)&lt;br /&gt;&lt;br /&gt;((mX + 0.43157974*mX*mX*mX)/(1 + 0.76443945*mX*mX + 0.05831938*mX*mX*mX*mX)/2/PI * 512&lt;br /&gt;&lt;br /&gt;ok: the 512 being the "degrees" on the nds ^^&lt;br /&gt;&lt;br /&gt;of course this is only valid on domain [-1,1] for mX so we have to shift around the circle a bit....&lt;br /&gt;&lt;br /&gt;and finally i got the function working:&lt;br /&gt;&lt;br /&gt;int myAtan(float y, float x)&lt;br /&gt;{&lt;br /&gt; if ( fabs(x) &gt; fabs(y) )&lt;br /&gt; {&lt;br /&gt;     if (x &gt; 0){&lt;br /&gt; float mX = -y/x;&lt;br /&gt; return (int)((mX + 0.43157974*mX*mX*mX)/(1 + 0.76443945*mX*mX + 0.05831938*mX*mX*mX*mX)/2/PI * 512 +  256+ 128 + 1024) % 512;&lt;br /&gt;     //return 0;&lt;br /&gt;     }&lt;br /&gt;     else&lt;br /&gt;     {&lt;br /&gt; float mX = -y/x;&lt;br /&gt; return (int)((mX + 0.43157974*mX*mX*mX)/(1 + 0.76443945*mX*mX + 0.05831938*mX*mX*mX*mX)/2/PI * 512 +  0 + 128 + 1024) % 512;&lt;br /&gt;     //return 0;&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt;     if (y &gt; 0){&lt;br /&gt; float mX = x/y;&lt;br /&gt; return (int)((mX + 0.43157974*mX*mX*mX)/(1 + 0.76443945*mX*mX + 0.05831938*mX*mX*mX*mX)/2/PI * 512 +  256 + 1024) % 512;&lt;br /&gt; return 0;&lt;br /&gt;     }else{&lt;br /&gt; float mX = x/y;&lt;br /&gt; return (int)((mX + 0.43157974*mX*mX*mX)/(1 + 0.76443945*mX*mX + 0.05831938*mX*mX*mX*mX)/2/PI * 512 +  0 + 1024) % 512;&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;yes fabs() is present, haha!&lt;br /&gt;&lt;br /&gt;in dragging a sprite around another sprite you get the differences in position x, and y:&lt;br /&gt;&lt;br /&gt;distX = touchXY.px - buttonXa; // x position of the dragged sprite - original position&lt;br /&gt;distY = touchXY.py - buttonYa; // the same for the y&lt;br /&gt;&lt;br /&gt;stupid enough ( i have to change this) i switched the x an y around in the function call:&lt;br /&gt;&lt;br /&gt;int myAngle = (int)myAtan(positionX, positionY);&lt;br /&gt;&lt;br /&gt;but it gives the angle and an arrow (giving power by dragged distance) displays the right direction and can be fired by letting go of the dragged sprite....&lt;br /&gt;&lt;br /&gt;the dragging of the sprite also posed some problems, which will be documented in another blog...&lt;br /&gt;&lt;br /&gt;of course after doing this, i tried the atan again, and it worked......&lt;br /&gt;all written above is discarded, haha!!!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jq__kevBr8s/SFk8ep6Yk3I/AAAAAAAAAzk/f6vCuQBszy0/s1600-h/nds.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_Jq__kevBr8s/SFk8ep6Yk3I/AAAAAAAAAzk/f6vCuQBszy0/s320/nds.jpg" alt="" id="BLOGGER_PHOTO_ID_5213264541002535794" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-4932301127372529525?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4932301127372529525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/4932301127372529525'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/06/nds-and-atan.html' title='nds and the atan'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Jq__kevBr8s/SFk9OWmKvbI/AAAAAAAAAzs/DLaOWX_9zOs/s72-c/atan.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-8287635022370925599</id><published>2008-06-06T07:17:00.000-07:00</published><updated>2008-06-19T02:50:12.112-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='timer'/><category scheme='http://www.blogger.com/atom/ns#' term='irq'/><category scheme='http://www.blogger.com/atom/ns#' term='interrupt'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>nds and the timer</title><content type='html'>Timers are important in games, steering animations, limiting actions.&lt;br /&gt;in Director there is the actionlist, and the stepFrame handler in parent scripts&lt;br /&gt;in Java you have the Thread()&lt;br /&gt;for the nds, all is a bit different, but in the end probably easier (?)&lt;br /&gt;&lt;br /&gt;//----------------------first  remarks, hardware timers and interrupts -----&lt;br /&gt;You start with interrupts the irq, this is the basis for getting timed actions.&lt;br /&gt;Then you discover the 4 timers the nds has....a timer is a set of registers hooked on the interrupt, it goes like this:&lt;br /&gt;&lt;br /&gt;TIMER0_CR = 0;&lt;br /&gt;TIMER0_DATA = TIMER_FREQ(5);&lt;br /&gt;TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1 | TIMER_IRQ_REQ;&lt;br /&gt;irqSet(IRQ_TIMER0, yourHandler); //hooking the handler to the interrupt&lt;br /&gt;irqEnable(IRQ_TIMER0);//enabling this special interrupt.&lt;br /&gt;&lt;br /&gt;you can set a handler (called "&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;VoidFunctionPointer") &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;to each interrupt mask, not only timers.&lt;br /&gt;&lt;br /&gt;The nds has for hardwaretimers for each screen, this link tells all about these timers:&lt;br /&gt;&lt;a href="http://www.double.co.nz/nintendo_ds/nds_develop8.html"&gt;http://www.double.co.nz/nintendo_ds/nds_develop8.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.double.co.nz/nintendo_ds/nds_develop2.html"&gt;&lt;/a&gt;&lt;br /&gt;Problem with these timers is that the wi connection uses them too, so in your game these timers must either be used with care or not at all.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.double.co.nz/nintendo_ds/nds_develop2.html"&gt;http://www.double.co.nz/nintendo_ds/nds_develop2.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So better is to use the VBLANK interrupt of the nds.&lt;br /&gt;You have to use a method based on swiWaitForVBlank()&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;start the interrupts:&lt;br /&gt;&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;void irqInit&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;();&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;two ways to associate a handler with the interrupt.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;void irqInitHandler&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;VoidFunctionPointer handler&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;void irqSet&lt;br /&gt;(IRQ_MASK irq, VoidFunctionPointer handler;//this is the hooking one&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;the last one triggers on&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;IRQ_VBLANK&lt;br /&gt;so:&lt;br /&gt;&lt;pre&gt;irqSet(IRQ_VBLANK, yourHandler);&lt;/pre&gt;&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;activate&lt;br /&gt;void irqEnable ( IRQ_MASK irq );&lt;br /&gt;stop&lt;br /&gt;void irqDisable ( IRQ_MASK irq );&lt;br /&gt;&lt;br /&gt;(but you need the timer or interrupt all the time, so why stop it?)&lt;br /&gt;&lt;br /&gt;i didn't find too much docs on this subject: (in french)&lt;br /&gt;&lt;a href="http://www.playeradvance.org/forum/showthread.php?t=6103"&gt;http://www.playeradvance.org/forum/showthread.php?t=6103&lt;/a&gt;&lt;br /&gt;some in english:&lt;br /&gt;&lt;a href="http://osdl.sourceforge.net/main/documentation/misc/nintendo-DS/homebrew-guide/HomebrewForDS.html"&gt;http://osdl.sourceforge.net/main/documentation/misc/nintendo-DS/homebrew-guide/HomebrewForDS.html &lt;/a&gt;&lt;br /&gt;and why not? here to practice your spanish: (interesting example included)&lt;br /&gt;&lt;a href="http://www.elotrolado.net/hilo_ds-ds-code-1-quot-interrumpiendo-quot_579855"&gt;http://www.elotrolado.net/hilo_ds-ds-code-1-quot-interrumpiendo-quot_579855&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);font-family:Georgia,serif;" &gt;so i tried this, having several sprites to rotate:&lt;br /&gt;&lt;br /&gt;irqSet(IRQ_VBLANK, NULL);&lt;br /&gt;irqClear ( IRQ_VBLANK );&lt;br /&gt;irqSet( IRQ_VBLANK, yourHandler );//&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;yourHandler  being the things to do every time&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;irqEnable( IRQ_VBLANK );&lt;br /&gt;&lt;br /&gt;but then the movement was incredibly slow....about 3 times a sec?&lt;br /&gt;&lt;br /&gt;fiddling around i got this solution: also start the HBLANK interrupt:&lt;br /&gt;&lt;br /&gt;irqEnable( IRQ_VBLANK );//only enable the VBLANK -  HBLANK only did not work....&lt;br /&gt;&lt;br /&gt;irqSet(IRQ_HBLANK, NULL);&lt;br /&gt;irqClear ( IRQ_HBLANK );&lt;br /&gt;irqSet( IRQ_HBLANK, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;yourHandler &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;);//hook function to HBLANK&lt;br /&gt;irqEnable( IRQ_HBLANK );&lt;br /&gt;&lt;br /&gt;with HBLANK set after enabling VBLANK the movement was incredibly fast, so slowing down things in the movementhandler:&lt;br /&gt;&lt;br /&gt;u8 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;timerCounter1 ; //a global entry, or static (whatever language you are used to)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;u8 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;timerCounter2 ; //another one&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;void &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;yourHandler &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;()&lt;br /&gt;{&lt;br /&gt; if ( ++timerCounter1% 32 == 0) //&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;timerCounter being a u8  divided by 32 gives the right speed for me, experiment!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;    {&lt;br /&gt;//do your stuff here&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt; if ( ++timerCounter2 % 16 == 0) //this one is 2 times as fast, you can go a lot faster if needed!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;    {&lt;br /&gt;//do your fast stuff here&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;&lt;code style="white-space: nowrap; color: rgb(0, 0, 0);"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;span style="font-family:Georgia,serif;"&gt;}&lt;br /&gt;&lt;br /&gt;now you have control over speed of movement.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;span style="color: rgb(0, 0, 0);" class="highlite"&gt;&lt;/span&gt;&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;//-----------------second part of the remarks about timers&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;Quite important is to realize how to use the timers.&lt;br /&gt;In DIRECTOR you have the actorList, which gives the possibility of parentscripts using the function on stepFrame, these scripts have to be put in the actorList to start and removed from this actorList to stop.&lt;br /&gt;in FLASH you can use the timer, this class just gives a signal when finishing the indicated period of time (you can start it again if necessary.)&lt;br /&gt;In Java threads are used.&lt;br /&gt;&lt;br /&gt;On the nds, you have this interrupt timer, and you have to hook in, in this process, and leave it.&lt;br /&gt;This requires that you organize your processes.&lt;br /&gt;&lt;code style="white-space: nowrap;"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;for instance:&lt;br /&gt;&lt;br /&gt;rotation a of sprite steered by the timer/interrupt,&lt;br /&gt;hook this process to this timer when starting the game&lt;br /&gt;&lt;br /&gt;when the player reaches a certain state, get the rotation of the timer&lt;br /&gt;but don't stop the timer. (Other rotations of movement might still need it...)&lt;br /&gt;&lt;br /&gt;different frequencies has to be obtained using the % function:&lt;br /&gt;if (++counter % 5 == 1) only fires one time in 5&lt;br /&gt;&lt;br /&gt;so thinking becomes different, although you can quickly organize a "timer array" with all the speed you need and let some function check this array.&lt;br /&gt;&lt;br /&gt;again: the nds lets you get to the basis of concepts and gives you the freedom of assembling the things your way, from all kinds of basic elements.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-8287635022370925599?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8287635022370925599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8287635022370925599'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/06/nds-and-timer.html' title='nds and the timer'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-6300154468314639140</id><published>2008-06-02T00:29:00.000-07:00</published><updated>2008-06-06T08:43:55.153-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rotation'/><category scheme='http://www.blogger.com/atom/ns#' term='sprites'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>sprite details and rotations</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jq__kevBr8s/SElDbXoQawI/AAAAAAAAAzU/ps-WCD1ey58/s1600-h/gameSprites32.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 258px; height: 23px;" src="http://1.bp.blogspot.com/_Jq__kevBr8s/SElDbXoQawI/AAAAAAAAAzU/ps-WCD1ey58/s320/gameSprites32.bmp" alt="" id="BLOGGER_PHOTO_ID_5208768581509081858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All in the nds is a bit different from what I expected.&lt;br /&gt;Ok, if you have solved the puzzle it becomes clear that indeed it is what the tuto's and the examples "say". But you have to understand the words in their context. And you can understand it differently depending on what you thought to understand from other programming environments.&lt;br /&gt;&lt;br /&gt;So i hope to "say" things a bit more clear, for people starting programming the nds, coming from DIRECTOR or FLASH kind of environments.&lt;br /&gt;&lt;br /&gt;So again: sprites are separate from their palettes and now it turns out separate from their rotations!&lt;br /&gt;&lt;br /&gt;Example: Say, you have a few sprites, 16 x 16 pixels, 256 colors (so one palette for all)&lt;br /&gt;&lt;br /&gt;Then you load these sprites as a sequence: (see also above)&lt;br /&gt;&lt;br /&gt;this is an image consisting of 11 sprites: (of course a bit larger then for the nds, :-)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jq__kevBr8s/SElDa1iMf2I/AAAAAAAAAzM/ma_DTANphCo/s1600-h/gameSprites.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 643px; height: 56px;" src="http://3.bp.blogspot.com/_Jq__kevBr8s/SElDa1iMf2I/AAAAAAAAAzM/ma_DTANphCo/s320/gameSprites.bmp" alt="" id="BLOGGER_PHOTO_ID_5208768572356853602" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;the magenta colour counts as transparent, and the "replay" text consists of three sprites...&lt;br /&gt;&lt;br /&gt;You have to initialize it like that:&lt;br /&gt;&lt;br /&gt;setSprites(SCREEN_SUB, &amp;amp;gameSprites_tls, gameSprites_tls_size, &amp;amp;gameSprites_pal, gameSprites_pal_size);&lt;br /&gt;(depending on your method, you have to provide screen number, the tiles, tileSize, palette, paletteSize....)&lt;br /&gt;&lt;br /&gt;(but the main thing is: all "sprites" are put in at once, this is: put in memory, not yet on the screen.)&lt;br /&gt;&lt;br /&gt;now you have to put a piece of this long thing on the screen as "a sprite":&lt;br /&gt;&lt;br /&gt;setSprite(SCREEN_SUB,  0 , 0, 0, 200, 10 );&lt;br /&gt;setSprite(SCREEN_SUB,  1 , 1, 0, 200, 30 );&lt;br /&gt;setSprite(SCREEN_SUB,  2 , 1, 0, 200, 50 );&lt;br /&gt;setSprite(SCREEN_SUB,  3 , 2, 3, 200, 70 );&lt;br /&gt;setSprite(SCREEN_SUB,  4 , 2, 2, 200, 90 );&lt;br /&gt;&lt;br /&gt;where&lt;br /&gt;the first indicates the screen,&lt;br /&gt;the second: the number (actually in the OAM) of your sprite to be&lt;br /&gt;the third is the index of which rotation is linked to this sprite, some are linked to the same rotation!&lt;br /&gt;the fourth: which piece of the long strip is going to make it to be your sprite&lt;br /&gt;fifth, sixth: x and y&lt;br /&gt;&lt;br /&gt;now if you want to play with your sprite: moving it:&lt;br /&gt;you have to refer to the sprite number (inOAM) so this is the second number:&lt;br /&gt;&lt;br /&gt;moveSprite(SCREEN_MAIN, 3 , posX, posY ); //or methods like this&lt;br /&gt;so here i move sprite 3, to position posX, posY&lt;br /&gt;&lt;br /&gt;but watch carefully now:&lt;br /&gt;rotating the same sprite:&lt;br /&gt;rotateSprite(SCREEN_MAIN,   2 ,   rotX  );&lt;br /&gt;but since sprite 4 is linked to this rotation, it will move to!!!!&lt;br /&gt;actually you change the rotation number 2, and with this the sprites which are linked to it.&lt;br /&gt;&lt;br /&gt;so rotateSprite, as a name is not very well chosen: better changeRotation, or something....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-6300154468314639140?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/6300154468314639140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/6300154468314639140'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/06/sprite-rotations.html' title='sprite details and rotations'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Jq__kevBr8s/SElDbXoQawI/AAAAAAAAAzU/ps-WCD1ey58/s72-c/gameSprites32.bmp' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-2732476532689231321</id><published>2008-06-01T00:37:00.000-07:00</published><updated>2008-06-07T07:09:03.326-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='makefile'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>Makefile monsters</title><content type='html'>&lt;span style="font-family:arial;"&gt;Having the incredible urge to make a game for the nds, you dont think of the makefile.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;You think of your game!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;After having sniffed at all sorts of examples you try something of your own, and "Fi Donc!", (french for all kinds of trouble!), the makefile doesn't quite let you taste the sweetness of succes....:-(&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;What is this monster? This is a file with rules how to link all the things you have put together in your project, and, finally presenting the code, the images, the sounds to the devkitpro, to let it be crunched and digested. All of which has to be done to be able to produce the miracle .nds file, which can be put in the emulators or the nds itself.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Wow!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;You can do this by hand too!&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://www.dev-scene.com/NDS/Tutorials_Day_2#Build_A_Demo_The_Hard_Way"&gt;http://www.dev-scene.com/NDS/Tutorials_Day_2#Build_A_Demo_The_Hard_Way&lt;br /&gt;&lt;/a&gt;&lt;span style="font-family:arial;"&gt;the name of this link speaks for itself.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;There is some luck around the corner: you are not the first to confront this....&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Killroy was here! is written on this wall, and whoever it was, they were good!!!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;They have created templates for the makefile.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Want to see a not so template makefile?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Look at this sound example:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://www.double.co.nz/nintendo_ds/nds_develop4.html"&gt;http://www.double.co.nz/nintendo_ds/nds_develop4.html&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;and download and open this makefile, it shows its working very clearly, totally dedicated to this very instructive sound project!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Then go to the devkitpro examples, there you see more generic makefiles, although the methods to work with sprites differ, so, the even the generic makefiles will differ amongst themselves.&lt;br /&gt;&lt;br /&gt;in between and writing about the "old" style and the "new" is this link:&lt;br /&gt;&lt;a href="http://www.fampennings.nl/maarten/nds/index.htm"&gt;http://www.fampennings.nl/maarten/nds/index.htm&lt;/a&gt;&lt;br /&gt;here the workings are explained fixing the watch example in de Devkitpro examples in the meantime, and expanding on the two processors ARM7 and ARM9.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Now that you now the why and the how, you can go and talk to these monster makefiles...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;what helps to is searching a tutorial on makefile, although this tends to be too general, you can extract some rules and get used to the very short commands....&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://www.opussoftware.com/tutorial/TutMakefile.htm"&gt;http://www.opussoftware.com/tutorial/TutMakefile.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;I use C++ Visual Express for the moment to compile my test projects:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;page of devkitpro explaining how to set up:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://www.devkitpro.org/index.php?s=cpp"&gt;http://www.devkitpro.org/index.php?s=cpp&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;(yes, it must be a makefile project)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In the project folder has to be placed the makefile.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;In my experience, with projects with a few sprites sounds, and images for backgrounds, the compiler always forgot "something". Cleaning the project didn't help. So i didn't clean anymore, just where the compiler provided errors on images or sounds, i removed these files (all of them  .o, .bmp etc of the same name) and generated the project again, this saves compiling time and finally it worked.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Why didn't it work either at once, or not? Computerprogramming is an exact science, no? No comprende! (Spanish for all sorts of trouble!) Maybe my RAM is not sufficient, maybe devkitpro is strange????&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;later on (in nds traditions never) there will be more on makefiles!!!&lt;br /&gt;&lt;br /&gt;this is the offcial description:&lt;br /&gt;&lt;a href="http://www.gnu.org/software/make/manual/make.html"&gt;http://www.gnu.org/software/make/manual/make.html&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-2732476532689231321?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2732476532689231321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/2732476532689231321'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/06/makefile-monsters.html' title='Makefile monsters'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-8368125288533607342</id><published>2008-05-31T23:57:00.000-07:00</published><updated>2008-06-07T07:22:45.065-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sound'/><category scheme='http://www.blogger.com/atom/ns#' term='microphone'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>Sound</title><content type='html'>What is a game without sound? What is anything without sound?&lt;br /&gt;What is even (our experience of) space without sound???&lt;br /&gt;&lt;br /&gt;So sound is important.&lt;br /&gt;But first of all, you want to have pictures, movement, and or levels in your game.&lt;br /&gt;Ok, if you are on your way with this sound has to be added.&lt;br /&gt;&lt;br /&gt;Difficult?&lt;br /&gt;&lt;br /&gt;Hmmmm, as everything on the ds, somehow difficult, after a while less so.&lt;br /&gt;&lt;br /&gt;16 channels!&lt;br /&gt;&lt;br /&gt;The first "layer" is not too difficult, but it can become complex, just because also sound is complex, not just sprites!&lt;br /&gt;&lt;br /&gt;links:&lt;br /&gt;the simple devkitpro example: sound is very instructive and shows how easy it is, it gives two examples in one:&lt;br /&gt;see all code there:&lt;br /&gt;&lt;br /&gt;//first way setting up:&lt;br /&gt;// set the generic sound parameters&lt;br /&gt;&lt;br /&gt;setGenericSound( &lt;br /&gt;          11025,    /* sample rate */&lt;br /&gt;          127,    /* volume */&lt;br /&gt;          64,    /* panning */&lt;br /&gt;          1 );    /* sound format*/&lt;br /&gt;&lt;br /&gt;//second way:&lt;br /&gt;TransferSoundData blaster = {&lt;br /&gt;   &lt;br /&gt;      blaster_raw,        /* Sample address */&lt;br /&gt;      blaster_raw_size,    /* Sample length */&lt;br /&gt;      11025,            /* Sample rate */&lt;br /&gt;      127,            /* Volume */&lt;br /&gt;      64,            /* panning */&lt;br /&gt;      1             /* format */&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;both are simple to implement and understand:&lt;br /&gt;&lt;br /&gt;if ( keys &amp;amp; KEY_A) playGenericSound(saberoff_raw, saberoff_raw_size);&lt;br /&gt;&lt;br /&gt;  //using first setting up &lt;br /&gt;if ( keys &amp;amp; KEY_R) playSound(&amp;amp;blaster); //second&lt;br /&gt;&lt;br /&gt;Preparation:&lt;br /&gt;the sounds have to be prepared in sox, from a .wav fromat to a .raw format, can be included like that and it works!&lt;br /&gt;but then you need a loop sound!!!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.double.co.nz/nintendo_ds/nds_develop4.html"&gt;http://www.double.co.nz/nintendo_ds/nds_develop4.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here you can read more about the sound settings, and see that it might become a bit more complex!&lt;br /&gt;difference between one shot and loop!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://nocash.emubase.de/gbatek.htm#dssound"&gt;http://nocash.emubase.de/gbatek.htm#dssound&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here apparently are the registers the sound uses, and then you can really master sound!&lt;br /&gt;&lt;br /&gt;Another detail: (why keep it simple?)&lt;br /&gt;there are two processors, the more complex examples shift the sound control to the ARM7, instead of the game which is located on the ARM9. This asks for an extra line in the makefile monster of course....more experience needed!&lt;br /&gt;&lt;br /&gt;a link we met before does a lot of explaining, in section 4.1 - 4.4 :&lt;br /&gt;&lt;a href="http://www.fampennings.nl/maarten/nds/index.htm"&gt;http://www.fampennings.nl/maarten/nds/index.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;But what a minute:&lt;br /&gt;You can record sound, or use the microphone actively in a game!&lt;br /&gt;the last links next entry is the DS Sound Capture. FUN!&lt;br /&gt;(Let the player get her next levels only after shouting in the mic! )&lt;br /&gt;This stays an idea for the moment!&lt;br /&gt;&lt;br /&gt;in great nds tuto traditions, we leave the remarks on sounds in this unfinishe state!!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-8368125288533607342?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8368125288533607342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/8368125288533607342'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/05/sound.html' title='Sound'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-7058731829528642122</id><published>2008-05-29T07:51:00.000-07:00</published><updated>2008-06-06T07:17:47.779-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tiles'/><category scheme='http://www.blogger.com/atom/ns#' term='palette'/><category scheme='http://www.blogger.com/atom/ns#' term='oam'/><category scheme='http://www.blogger.com/atom/ns#' term='sprites'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>nds sprites intro</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;Strange: there are a few nds sprites tuto's around, and very good ones, but somehow these are also very much starters and then most of them are suddenly incomplete.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Suddenly? Yes, they leave out the palet problem, or the problem of more then one sprite, or just stop the text!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt; Introduction to &lt;a href="http://patater.com/manual"&gt;Nintendo DS Programming&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: arial;" href="http://patater.com/manual"&gt; of&lt;span class="firstname"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;Jaeden&lt;/span&gt; &lt;/a&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;a href="http://patater.com/manual"&gt;Amero&lt;/a&gt;&lt;br /&gt;is an exception, but unfortunately his examples have variables in it that won't compile in my PC (such as the temporary oam: toam ). (Due to my first try in PALIB and installing not the latest version of devkitpro?)(I have to try to run it in Visuall C++ express...)&lt;br /&gt;&lt;br /&gt;What is the problem with sprites, these beasts being so well managed nowadays in DIRECTOR or FLASH?&lt;br /&gt;&lt;br /&gt;well, for a start they have to be put in the nds, in the memory&lt;br /&gt;the ds has to be prepared for this in the videomode&lt;br /&gt;you have to prepare the sprites images in certain formats&lt;br /&gt;these images consisting of (tiles bits broken up) and palettes have to be included using the makefile monster.&lt;br /&gt;Who did ask this makefile monster to join the party?&lt;br /&gt;&lt;br /&gt;If coming from DIRECTOR, FLASH you have to rethink your sprites ideas:&lt;br /&gt;for instance: if working with a 256b color palette, there is only one palette so what you actually construct is one big image and you pick out the sprites by an extra index.&lt;br /&gt;So you load the whole alphabet as a sprite, and you get the E by indexing on 4 (starting with 0 of course). Then your sequence of letters has all the same palette.&lt;br /&gt;Nice example:&lt;br /&gt;&lt;a href="http://liranuna.drunkencoders.com/misc-projects/tileoptimize/"&gt;http://liranuna.drunkencoders.com/misc-projects/tileoptimize/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Examples can be found in devkitpro, but if you look carefully the examples are depending on the makefile and sometimes using grit, or other similar but different progs (&lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:100%;"  &gt;gfx2gba)&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;, sometimes reading in bmp files, all kinds of possibilities, but my experience was that: ok this is functioning, but why?&lt;br /&gt;&lt;br /&gt;examples of devkitpro online for the latest updates:&lt;br /&gt;&lt;a href="http://devkitpro.cvs.sourceforge.net/devkitpro/examples/nds/"&gt;http://devkitpro.cvs.sourceforge.net/devkitpro/examples/nds/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;so we have to scramble sites and blogs to get an idea how this works.&lt;br /&gt;for me the main problem was getting a view on the problems! (The differences with my previous encounters with sprites...)&lt;br /&gt;&lt;br /&gt;List of problems&lt;br /&gt;&lt;br /&gt;0. which programming environment to use: (after installing devkitpro)&lt;br /&gt;1. the dependency on the makefile (functioning in the folder devkitpro...),&lt;br /&gt;2. what is the grit (or others, &lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:100%;"  &gt;gfx2gba, .pcx&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;) relation, how to make the images readable for C and the nds&lt;br /&gt;3. how to prepare the nds video mode (seems easy!)&lt;br /&gt;4. how to get these data and palettes into the right spot in the memory of the nds&lt;br /&gt;&lt;br /&gt;Solutions and answers:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;0. which programming environment to use:&lt;br /&gt;Programmers notepad is ok, but running slow and not always compiling the examples in the same way.&lt;br /&gt;Visual Express C++, quite a monster but in my experience far more suited, you have to rebuild the examples using: &lt;a href="http://www.devkitpro.org/index.php?s=cpp"&gt;http://www.devkitpro.org/index.php?s=cpp&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;1. the dependency on the makefile (functioning in the folder devkitpro...),&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;.... is still a bit unknown territory for me, related to devkitpro, study in progress&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;2. what is the grit (or others, &lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:100%;"  &gt;gfx2gba&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;) relation, how to make the images readable for C and the nds&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;....idem&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;, the main problem &lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;being &lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;not grit but the dependency on the makefile, study in progress&lt;br /&gt;examples in devkitpro:&lt;br /&gt;Complex_2D, has all the OAM and sprite functions, reads in a pcx image&lt;br /&gt;Sprite_Bitmap, makes its own (simple) sprites&lt;br /&gt;some homebrew have .git and .grit files (by wingit.exe)&lt;br /&gt;some homebrew use &lt;/span&gt;&lt;span style=";font-family:Courier New;font-size:100%;"  &gt;gfx2gba&lt;/span&gt;.exe &lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;and get .tls and .pal and .map files&lt;br /&gt;some read the image immediately&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;3. how to prepare the nds video mode (seems easy!)&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;All kinds of choices for sprites you need a text mode (texture mode), for the screen with the sprites, MAIN or SUB, see (for instance)&lt;br /&gt;&lt;a href="http://www.tobw.net/dswiki/index.php?title=Graphic_modes"&gt;http://www.tobw.net/dswiki/index.php?title=Graphic_modes&lt;/a&gt;&lt;br /&gt;or the very extended (but suddenly stopping)&lt;br /&gt;&lt;a href="http://www.dev-scene.com/NDS/Tutorials_Day_2"&gt;http://www.dev-scene.com/NDS/Tutorials_Day_2&lt;/a&gt;&lt;br /&gt;or again on dev-scene:&lt;br /&gt;&lt;a href="http://dev-scene.com/NDS/DOCgraphicmodes"&gt;http://dev-scene.com/NDS/DOCgraphicmodes&lt;/a&gt;&lt;br /&gt;For this problem you can compare the examples and learn a lot about this Videomode.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;4. how to get these data and palettes into the right spot in the memory of the nds&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;to get the picture of the OAM memory, look at this here (a french site but the picture is universal!) &lt;a href="http://www.dev-fr.org/wiki/nds/doku.php?id=dssprite"&gt;http://www.dev-fr.org/wiki/nds/doku.php?id=dssprite&lt;/a&gt;&lt;br /&gt;you can see what 's happening with your sprite, data-part gfx, it gets split up in tiles!&lt;br /&gt;but what happens with the pallette, they dont tell!&lt;br /&gt;&lt;br /&gt;This we can read in &lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;a href="http://patater.com/manual"&gt;Nintendo DS Programming&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: arial;" href="http://patater.com/manual"&gt; of&lt;span class="firstname"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;Jaeden&lt;/span&gt; &lt;/a&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;a href="http://patater.com/manual"&gt;Amero&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;a few very useful details about tiles and palettes, coming from this text:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;There are two ways to tile sprites, 1D and 2D. In a 2D                 layout, the sprite memory is treated like a giant image from                 which sprite tiles are obtained by making a box the size of the                 sprite and placing it over the giant image. In a 1D layout, the                 sprites are layed out in a linear fashion,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Sprites can be made of tiles that use 16 colors or of ones that                 use 256 colors.&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: arial;" href="http://liranuna.drunkencoders.com/nds-2d-tuts/lesson-3/#The%20Palette%20-%20How%20it%20really%20looks"&gt;liranuna &lt;/a&gt;&lt;span style="font-family:arial;"&gt;gives a picture, this is my own:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jq__kevBr8s/SEOnT-j0F1I/AAAAAAAAAzE/fcHE4rfqdSE/s1600-h/palette.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://1.bp.blogspot.com/_Jq__kevBr8s/SEOnT-j0F1I/AAAAAAAAAzE/fcHE4rfqdSE/s320/palette.jpg" alt="" id="BLOGGER_PHOTO_ID_5207189555822991186" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Tiles that use 256 colors are twice as large as                 tiles that use only 16 colors. Another advantage of using                 16-color sprites is the ability to use 16 different palettes.                 When using 256-color sprites, each sprite (and tile) must use                 the same palette. When using 16-color sprites, we can have one                 sprite use one 16-color palette and another sprite use a                 different 16-color palette, even though both use the same tile                 data.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;then you have to prepare the OAM, well this is everywhere the same and easy.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;see again: &lt;a href="http://patater.com/manual"&gt;Nintendo DS Programming&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: arial;" href="http://patater.com/manual"&gt; of&lt;span class="firstname"&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;Jaeden&lt;/span&gt; &lt;/a&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;a href="http://patater.com/manual"&gt;Amero&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;then you have to get your spites in, this is low level, and all these functions can be put away in a sprite.c file, but there is no general sprite.c file around! Everyone makes his own, which is much more detailed then is shown in the examples.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;in full tradition of all what is written on the nds:&lt;br /&gt;&lt;br /&gt;more in blog sprites details!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;text in progress&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;" class="surname"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-7058731829528642122?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7058731829528642122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/7058731829528642122'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/05/nds-sprites.html' title='nds sprites intro'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Jq__kevBr8s/SEOnT-j0F1I/AAAAAAAAAzE/fcHE4rfqdSE/s72-c/palette.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-5115724191902352587.post-618260589381895581</id><published>2008-05-22T12:14:00.000-07:00</published><updated>2008-06-08T22:26:07.813-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tuto'/><category scheme='http://www.blogger.com/atom/ns#' term='links'/><category scheme='http://www.blogger.com/atom/ns#' term='nds'/><title type='text'>nds links</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;just a starter blog: first all kind of things...&lt;br /&gt;&lt;br /&gt;the start of nds programming coming from "normal" programming is a bit steep, due to the low level things with makefiles and images....&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;my first applications was an OpenGL thing, with models imported from BLENDER (with the export Python script)&lt;br /&gt;but OpenGL on the nds is sort of special feature...&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:arial;"&gt;then i reshaped a program just to show pictures above and some text below, a sort of slide show, or presenter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;then i bounced against the wall of the makefile&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;i was recoiled into sprites, &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;happened to stumble into tiles and maps&lt;br /&gt;etc etc etc&lt;br /&gt;&lt;br /&gt;emulators can be found...everywhere, i used DUALIS, now NO$GBA.EXE, sometimes: ideas.exe.&lt;br /&gt;the best experiences lately with&lt;br /&gt;NO$GBA.EXE&lt;br /&gt;&lt;a href="http://www.emulator-zone.com/doc.php/gba/nocashgba.html"&gt;http://www.emulator-zone.com/doc.php/gba/nocashgba.html&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;nearly all tuto's on the web about nds programming are not really finished, some stopping with sprites, others (sort of like this sentence) you have to scramble and try out, the list below is about the best there is...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;this is just a page where to find some readable (sometimes partial) tutorials&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;installing devkitpro is well covered&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;in devkitpro all kind of examples are given&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;the main problem of nds programming is the setting up, after that it becomes more and more just depending on yourideas and programming skills&lt;br /&gt;&lt;br /&gt;so first....&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;grit, gfx2gba.exe, PAGfx&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:arial;"&gt;backgrounds, tiles, maps, sprites, palettes&lt;br /&gt;VRAM, memory banks, registers, MODE&lt;br /&gt;then you can start wth your game and it becomes familiar OO...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Oh yes i forgot: you have to have something to run your program on, inside the DS, i wanted to have an R4, but that was not available and opted for a fire link card, this proved to be fine, having a direct USB link to the PC, and acting like an exteral hard disc. Some programs won't work, but ok....&lt;br /&gt;Memory 1 GB, seems to be a lot for these small progs.&lt;br /&gt;All kinds of pages about these cards, nearly too much.....&lt;br /&gt;&lt;br /&gt;Oh yes, most of the programming is done in C, although PALIB can be done in C++...&lt;br /&gt;but making sprites and nice maps is much more difficult! The planning becomes so important!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="highlite"  style="font-family:arial;"&gt;//---------------------------------------tuto's-----------------------------------------------&lt;br /&gt;&lt;a href="http://www.double.co.nz/nintendo_ds/index.html"&gt;homebrew &lt;/a&gt;(problem: info seems good but not all seems to work ...due to my fire link card???)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://liranuna.drunkencoders.com/nds-2d-tuts/"&gt;http://liranuna.drunkencoders.com/nds-2d-tuts/&lt;/a&gt;&lt;br /&gt;nice soft intro to getting tiles and maps into the nds (runs inside devkitpro)&lt;br /&gt;but the way it is programmed is quite different, older? then the devkitpro examples&lt;br /&gt;&lt;br /&gt;a very worthwhile manual:&lt;br /&gt;&lt;a href="http://patater.com/files/projects/manual/manual.html"&gt;http://patater.com/files/projects/manual/manual.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dev-scene.com/NDS/Tutorials_Day_1"&gt;http://www.dev-scene.com/NDS/Tutorials_Day_1&lt;/a&gt;&lt;br /&gt;of course this is very good, but this sequence stops at sprites, just where it matters most!&lt;br /&gt;&lt;br /&gt;this seems to cover a lot, but it uses GIMP with a Python script i cannot find (for windows)&lt;br /&gt;&lt;a href="http://www.dspassme.com/programmers_guide/tutorial/"&gt;http://www.dspassme.com/programmers_guide/tutorial/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;specifications&lt;br /&gt;&lt;a href="http://nocash.emubase.de/gbatek.htm"&gt;http://nocash.emubase.de/gbatek.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;this explains why and what about &lt;span style="font-weight: bold;"&gt;sprites&lt;/span&gt;, and these sprites seem to be a lot of work, but fun!&lt;br /&gt;&lt;a href="http://osdl.sourceforge.net/main/documentation/misc/nintendo-DS/graphical-chain/OSDL-graphical-chain.html"&gt;http://osdl.sourceforge.net/main/documentation/misc/nintendo-DS/graphical-chain/OSDL-graphical-chain.html&lt;br /&gt;&lt;/a&gt;coming from here:&lt;br /&gt;&lt;a href="http://osdl.sourceforge.net/main/documentation/misc/nintendo-DS/homebrew-guide/HomebrewForDS.html"&gt;http://osdl.sourceforge.net/main/documentation/misc/nintendo-DS/homebrew-guide/HomebrewForDS.html&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;then there is the PALIB&lt;br /&gt;&lt;a href="http://www.palib.info/Doc/PAlibDoc%20Fr/index.html"&gt;http://www.palib.info/Doc/PAlibDoc%20Fr/index.html&lt;/a&gt;&lt;br /&gt;it has something if you can develope in C++ Visual Express&lt;br /&gt;PALIB tuto: &lt;a href="http://www.palib.info/wiki/doku.php?id=day1"&gt;http://www.palib.info/wiki/doku.php?id=day1&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;//-------------------------------------openGL-----------------------------------------&lt;br /&gt;OpenGL examples can be found inside devkitpro, it feels like a bit of outside world in the nds programming and is pretty much like ... OpenGL :-)&lt;br /&gt;&lt;br /&gt;//-------------------something about makefiles------------------------&lt;br /&gt;&lt;a href="http://www.coranac.com/tonc/text/setup.htm"&gt;&lt;br /&gt;http://www.coranac.com/tonc/text/setup.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;//------------------------------------------------------------------------------------&lt;br /&gt;where to find some of the main free applications:&lt;a href="http://dshb.50webs.com/pages/hb.htm"&gt;&lt;br /&gt;http://dshb.50webs.com/pages/hb.htm&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ndshb.com/cgi-bin/cfiles/cfiles.cgi?0,0,0,0,12,135"&gt;http://www.ndshb.com/cgi-bin/cfiles/cfiles.cgi?0,0,0,0,12,135&lt;/a&gt;&lt;br /&gt;i like the chess program, the dsorganize and the dslinux, for a start...&lt;br /&gt;&lt;br /&gt;//---------------------------------------to get images in right shape for sprites or backgrounds&lt;br /&gt;&lt;br /&gt;Usenti, grit, wingrit, gfx2gba downloads:&lt;br /&gt;&lt;a href="http://www.coranac.com/projects/#usenti"&gt;http://www.coranac.com/projects/#usenti&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;//------------------------------------------------------------------------------------&lt;br /&gt;short tricks: (some things not worth a whole tuto, :-)&lt;br /&gt;&lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.double.co.nz/nintendo_ds/nds_develop2.html"&gt;swapping upper an lower screen&lt;/a&gt;&lt;span class="highlite"  style="font-family:arial;"&gt; (just: lcdSwap(); )&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;pre class="cpp"  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;lcdMainOnTop&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;; &lt;span style="color: rgb(255, 0, 0);"&gt;//MAIN renders to top screen SUB to bottom&lt;/span&gt;&lt;br /&gt;lcdMainOnBottom&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;; &lt;span style="color: rgb(255, 0, 0);"&gt;//SUB renders to top screen MAIN to bottom&lt;/span&gt;&lt;br /&gt;lcdSwap&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;; &lt;span style="color: rgb(255, 0, 0);"&gt;//swap the screens the egines were rendering to&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5115724191902352587-618260589381895581?l=nds-homebrew-hslleiden.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/618260589381895581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5115724191902352587/posts/default/618260589381895581'/><link rel='alternate' type='text/html' href='http://nds-homebrew-hslleiden.blogspot.com/2008/05/nds-links.html' title='nds links'/><author><name>underCover</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
