gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > C language, programs...basically everything in general...

#166005 - no one - Fri Jan 16, 2009 12:45 am

...as the title suggests i am what people call a complete beginner...im just wondering, ive got the programs (devkit pro and programmers notepad) but no ones actually got an actual beginners tutorial to use these programs...ive read the tutorial and got up to the first example...http://www.eskimo.com/~scs/cclass/notes/sx1a.html...but it doesnt say anything about a makefile or what, how and where to use a compiler, ive searched google they dont have anything let alone tutorials on how and what to press to compile a simple "hello world" program...nor is there a step by step picture tutorial specifying where i place...
cc -0 hello hello.c
...i typed up everything that, that (the link above) site suggested as a first example, when i run it i get ""make": *** No rule to make target `run'. Stop."...i searched that error up in both google and here and it says something about a getting/creating a makefile program or it just comes with the nds examples...i want to compile my first program but so far there has been no luck in me finding out "how to compile with devkit pro" and "how to "test" (as in running a practice run) a self written program to see if it works or not and/or what buttons to press to execute it"...the help site is of no help, there is apparently no contents for me to search up...
....and knowing the majority of people on such forums (or maybe its the fact i join the wrong forums) ill get loads of replies saying "dude you suck" or "are you really that nooby?" or if this thread works in the complete opposite and/or gets deleted or shoved into the back where all the old threads are held...call me a noob, flame me and tell me that i suck (even though i already know that) i dont care i just want some answers...i really want to learn how to program/create a gba rom...sorry if such a post has been posted and i have just duplicated it...and err sorry if i posted anything, defamatory, derogratory or offensive to anyone who reads this thread (which will probably be left unanswered)...

#166006 - Dwedit - Fri Jan 16, 2009 1:59 am

You don't need to insult yourself, people tend to be nice here.

I suggest you copy the template example from the devkitPro Examples directory. Modify the files until they become the example you are trying to create.

If you are indeed developing for the GBA, you can't just use stock example code, because you need to initialize IRQs in every GBA program, and call consoleinit before you can use printf.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#166007 - crazakp - Fri Jan 16, 2009 2:25 am

Do you know how to program in C? If not then you should focus on that first. Learn how to make simple programs in C. Then try increase the complexity of your programs till you get a good feel for it.

Then you can read some tutorials on GBA development. Here are a couple links to some tutorials.

Here's a tutorial that takes you step by step to create a pong game on the gba:
http://www.webbesen.dk/gba/default.asp

Tonc's guide (very detailed and explains a lot of things):
http://www.coranac.com/tonc/text/toc.htm

Drunken Coder's Tutorials:
http://www.drunkencoders.com/index.php?system_id=2&page=Tutorials

GBA Junkie's Tutorials:
http://gbajunkie.co.uk/


Those are the tutorials I reference as I'm just starting learn as well. Hope that helps.

#166008 - gauauu - Fri Jan 16, 2009 4:28 am

crazakp wrote:
Do you know how to program in C? If not then you should focus on that first. Learn how to make simple programs in C. Then try increase the complexity of your programs till you get a good feel for it.


This is probably the most important thing. If you haven't programmed before (which it sounds like you haven't?) is to learn programming on the PC first. GBA and DS programming is a pretty difficult starting place. Buy a beginner's programming book or look for a beginner's programming tutorial online (I wish I had a good recommendation, but it's been years since I first learned, so things have changed), and practice making cheesy games on your PC. When you feel like you have that under control (which could take awhile, depending on how naturally programming comes to you and how quick of a learner you are), then read those tutorials crazakp posted, particularly TONC.

As a generality, the TONC stuff is a good litmus test: if it mostly makes sense, you have enough background that GBA programming should be pretty doable. If it doesn't, I'd recommend spending a little more time learning C and programming in general.

I know that's not the answer that you probably want to hear, and I apologize for that.

To answer some of your specific questions: With devkitPro tools, there's there's very little "pressing" or "clicking" to do stuff. It's more about running certain command-line tools to do things to your files.

A brief (and quite lacking) summary:

-to compile, you run arm-eabi-gcc with your source file as a parameter. There's all sorts of ugly other parameters you will want to pass to arm-eabi-gcc, and you'll need to do this for all source files, which is why we recommend using make.

-make.exe will look for a special script, called Makefile, in the directory you run it from. The makefile tells what commands to run to compile your code, and when it should run them. Sort of like a batch file on crack. Luckily, devkitARM/libnds comes with a good general makefile. If you set up your project directory like the libnds examples, cd to the project directory, copy the makefile example, and type "make", it should start doing its magic.

-to run or test, you have to take the game rom and run it, either on the GBA (or DS) or an emulator. The easiest way to do this is to download VisualBoyAdvance and open the rom file you created. The more rewarding way is to transfer it to a GBA flash card (which varies depending on your card) and run it on the GBA.

Anyway, hopefully that will help some. Good luck with the journey!