#124084 - beamer30 - Tue Apr 03, 2007 2:01 am
ok i want to learn C but cant find any n00b tuts have you guys(i have already read the one in the stickie)
i also can't seem to compile anything in arm, i don't know why but it just won't compile any c++ lanuage ive treid
can someone just point me in the right direction for coding
#124086 - tepples - Tue Apr 03, 2007 2:14 am
"won't compile"? Please paste the error message here.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124154 - beamer30 - Tue Apr 03, 2007 6:04 pm
ok heres the code
Code: |
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
} |
a test to try ou arm, but
it can't find any compile just export to rtf html
please point me in the right direction im so confused
#124155 - Ant6n - Tue Apr 03, 2007 6:10 pm
read beginners faq?
"...Graphics
Q: How do I write text?..."
edit:
wait, are you actually using devkitpro? or ham? can only ouput to rtf, html?
#124157 - keldon - Tue Apr 03, 2007 6:25 pm
'It' will only export to rtf/html? Please elaborate exactly what 'it' is. And you posted the code, not the error message.
#124160 - beamer30 - Tue Apr 03, 2007 6:47 pm
ok sorry i should clarify this better:
i mean i don't nkow how to get the file into a working program
also iv'e read every tut i could find on this(yes the stickie too)
and they all make no sense at all to me im so confused im just wondering if someone here can teach me or give me a push in the right direction.
heres some questions i have if you have the ime to help
Code: |
how do i turn my script into a program
what are realy goo compile and what do i exactly need to have
how do i do any of this:
[b]"C:\devkitPro\devkitARM\bin\arm-eabi-gcc.exe. It's not something to be double-clicked; you'll have to use the command prompt. Most GCC users are familiar with their favorite operating system's command prompt. If you have never used a command prompt, learn DOS; the Windows command prompt is copied nearly wholesale from DOS's.
If you are using the Windows built-in command prompt instead of MSYS, you'll have to add the path of the folder containing arm-eabi-gcc.exe to your Path environment variable. To do this, type the following into a command prompt: set Path=C:\devkitPro\devkitARM\bin;%Path%
This may be easier if you set up a shell script. Most experienced users of GCC know what a shell script is; users of GCC on Microsoft platforms call shell scripts "batch files." If you don't know what a batch file is, please learn what a batch file is and how to make one before you start using GCC.
And remember: when linking a program, you'll need to specify the Thumb C library (-mthumb) that supports interworking (-mthumb-interwork) and the GBA memory layout (-specs=gba.specs for ROM or -specs=gba_mb.specs for multiboot), or you'll just get a white screen:
Code:
arm-eabi-gcc -Wall -mthumb -mthumb-interwork -specs=gba_mb.specs hello.c -o hello.elf
arm-eabi-objcopy -O binary hello.elf hello.mb"
[/b]
how do i use gcc( is there an eaisier option than gcc)
|
see im just super confused noob thats read all the tut and has no clue what hes doing please help me
#124173 - keldon - Tue Apr 03, 2007 8:40 pm
I have this feeling people are downloading the wrong download from the news section on devkit pro. What you want is the DevkitPro installer; if you have installed that then go to Start->All Programs->devKitPro->msys
When in there you can run make.
#124184 - Lynx - Tue Apr 03, 2007 10:31 pm
Also, if you are new to programming, you might want to check out PAlib.com for a "helper" lib that will making working with the DS a little easier.
_________________
NDS Homebrew Roms & Reviews
#124186 - gauauu - Tue Apr 03, 2007 10:43 pm
Actually, if you are as new to programming as it sounds like, I would stay far away from the gba and ds for awhile, buy a "C for dummies" type book, which will have much more in-depth explanations of what some of this stuff means, and work through it.
#124188 - Lick - Tue Apr 03, 2007 11:03 pm
Start using the Shift-key to write caps when needed! End sentences with a period (.) and not double line-breaks.
_________________
http://licklick.wordpress.com
#124192 - beamer30 - Tue Apr 03, 2007 11:32 pm
i've been there(in Msys) but what do i do from there just look at the black screen!!!!!!!!!!!!!!!!!!!!!!!!!!.........................
can someone please give me a simple noob tut so i can stop asking the same questions 40000000000000000000 times with no results!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(anger spweing from my body, massive intese anger.......................lol)
#124199 - poslundc - Wed Apr 04, 2007 1:07 am
Please clean up your messages and observe some basic forum etiquette, beamer30. Show some respect to the people you want help from.
There is a tutorial on setting up the Devkit Pro here. There are plenty of others out there, but unless you actually step through and follow them instead of just reading them they will do you little good.
Dan.
#124213 - beamer30 - Wed Apr 04, 2007 2:47 am
i didn't meen to make my post offendful it was soppuse to be funny lol XD,
thanks for the tut but i read it and am still super confused i couldn't even get the first part of the tut to work just came up with errors, is there any hope for me :(
#124222 - tepples - Wed Apr 04, 2007 6:32 am
Have you ever programmed anything that is intended to run on Microsoft Windows, on Mac OS X, or on GNU/Linux? I would recommend starting on one of those platforms before you start on the Game Boy Advance or the Nintendo DS.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124227 - Ant6n - Wed Apr 04, 2007 6:52 am
somebody should put in the beginners faq that people who don't know where to start should specify their prerequesite knowledge and what they are trying to achieve as a first and intermediary step, so that they can be more effectively helped
#124239 - keldon - Wed Apr 04, 2007 9:03 am
Good point, actually there are plenty of [free] IDE's that will do the job for beginning programming. Dev c++, Visual C++ Express and QBasic. In fact a Wrox c++ tutorial comes with every copy of Visual C++ Express.
So download Visual C++ Express
- http://msdn.microsoft.com/vstudio/express/visualc/
#124247 - KayH - Wed Apr 04, 2007 11:46 am
Additional hints (not complete!):
The Computer (PC, GBA,...) does not understand the language the developer (you) write (C/C++, Assembler, Basic, ...). The step to translate the written sourcecode (something similar to a written letter) is called "compile". With an additional step called "link" you create an executable file, which the computer understand and execute.
"Word" is not able to "compile"! You can only create the sourcecode with that, although this isn't a good editor for programming...
Nevertheless, when you saved your letter (sourcecode) as "my_first_program.cpp" (or similar) the next step will be compiling. For this you can use for example the DevkitPro compiler and toolchain. If you target is a windows PC you can use the "VisualStudio2005 express" for writing and compiling directly from the so called IDE.
HTH
KaY
#124311 - beamer30 - Thu Apr 05, 2007 1:44 am
Yes someone should, and yes i've made alot of code but with python.
Last edited by beamer30 on Thu Apr 05, 2007 5:36 am; edited 2 times in total
#124328 - HyperHacker - Thu Apr 05, 2007 2:58 am
KayH wrote: |
"Word" is not able to "compile"! You can only create the sourcecode with that, although this isn't a good editor for programming... |
You should use a text editor for coding, not a word processor. Those tend to save in their own formats and have things like autocorrect and other cleanliness features that will make coding a pain.
_________________
I'm a PSP hacker now, but I still <3 DS.
#124349 - beamer30 - Thu Apr 05, 2007 8:17 am
duh!?, after reading the stickie again and again and again and again and agian and again..................................................I finally figured out a question that can help me!!!!!!!!!!!!!!!
Question:
how do i compile the code i've made?
#124376 - gauauu - Thu Apr 05, 2007 3:36 pm
Run the compiler program with the compiler-specific command line parameters.
If you are using devkitPro, try something like this:
Code: |
arm-eabi-gcc -g -c -Wall -O3 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -Ic:/devkitPro/libgba/include characters.c -o characters.o |
Replacing characters.c and characters.o with the name of your file.
That will compile one source file down to an object file. It won't create the final application.
To do that, you need to do something like:
Code: |
arm-eabi-gcc -g -mthumb -mthumb-interwork -Wl,-Map,yourgamename.elf.map -specs=gba.specs characters.o -Lc:/devkitPro/libgba/lib -lgba -o yourgamename.elf |
If you have other source files, put them next to characters.o, seperated by spaces.
If you look at the sample makefiles that come with devkitPro, it automates this process, so you don't have to type all that crap. If you use the makefile template provided, then you can usually get away with just putting that makefile in your source directory, making sure the msys/bin directory is in your path, setting the devkitpro environment variable, and typing "make".
#124378 - KayH - Thu Apr 05, 2007 4:08 pm
HyperHacker wrote:
Quote: |
You should use a text editor for coding, not a word processor. Those tend to save in their own formats and have things like autocorrect and other cleanliness features that will make coding a pain.
|
I know this well. :-) And I don't say this is the way to go ... I only refer to the infos given from beamer30, which seems to indicate he uses this "program". ;-)
#124384 - tepples - Thu Apr 05, 2007 5:05 pm
Does somebody need to make a CamStudio recording of installing Dev-C++, entering a program, compiling it using MinGW, and then repeating the process with devkitARM?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124389 - Lick - Thu Apr 05, 2007 6:31 pm
#124408 - beamer30 - Thu Apr 05, 2007 8:31 pm
Lol, lick was that tut for me?
thanks for the tut Gauauu, but what is:
"the compiler program"
and how do i:
use the makefile template provided, then you can usually get away with just putting that makefile in your source directory, making sure the msys/bin directory is in your path, setting the devkitpro environment variable, and typing "make".
p.s thanks you all for helping me im learnng alot.(brain bulging with info)
#124411 - tepples - Thu Apr 05, 2007 8:49 pm
beamer30 wrote: |
but what is:
"the compiler program" |
GNU Compiler Collection. If you installed devkitARM to the default location, it should be "C:\devkitPro\devkitARM\bin\arm-eabi-gcc.exe".
Quote: |
and how do i:
use the makefile template provided |
Are you trying to make a GBA program or a DS program? Where did you save the source code?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124412 - gmiller - Thu Apr 05, 2007 8:53 pm
copy the template makefile into the folder that has your code in it then open up a msys session and get to the command prompt. At that prompt type "make" and hit return and the compiler will be run.
For example:
Code: |
gmiller@GDCND6251J15 ~
$ ls
DrawText.elf DrawText.gba.gz DrawText.vhw include makefile
DrawText.gba DrawText.vho build insight.ini source
gmiller@GDCND6251J15 ~
$ make
make "DEBUG_SET=" --no-print-directory -C build -f /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/Makefile
font.c
'C' THUMB Rule
arm-eabi-gcc -MMD -MP -MF /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/build/font.d -mthumb -mthumb-interwork -Wall -O3 -save-temps -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -I/c/devkitPro/devkitARM/include -I/c/devkitPro/libgba/include -I/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/include -I/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText -c /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/source/font.c -o font.o
helper.c
'C' THUMB Rule
arm-eabi-gcc -MMD -MP -MF /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/build/helper.d -mthumb -mthumb-interwork -Wall -O3 -save-temps -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -I/c/devkitPro/devkitARM/include -I/c/devkitPro/libgba/include -I/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/include -I/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText -c /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/source/helper.c -o helper.o
main.c
'C' THUMB Rule
arm-eabi-gcc -MMD -MP -MF /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/build/main.d -mthumb -mthumb-interwork -Wall -O3 -save-temps -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -I/c/devkitPro/devkitARM/include -I/c/devkitPro/libgba/include -I/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/include -I/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText -c /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/source/main.c -o main.o
linking cartridge
arm-eabi-gcc -Wl,-Map,DrawText.elf.map -specs=gba.specs font.o helper.o main.o -L/c/devkitPro/libgba/lib -o /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/DrawText.elf
built ... DrawText.gba
gbafix /c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText/DrawText.gba
ROM fixed!
gmiller@GDCND6251J15 ~
$ pwd
/c/cygwin/home/gmiller/ham/Sources/Chapter05/DrawText
gmiller@GDCND6251J15 ~
$
|
This process crated object files for each 'C' source file and then linked them into a complete program. The program was then modified by 'gbafix' to produce a '.gba' file that can be flashed to a GBA cart or run in the GBA emulators.
#124421 - gauauu - Thu Apr 05, 2007 10:32 pm
beamer30 wrote: |
thanks for the tut Gauauu, but what is:
"the compiler program"
|
What tepples said is correct, but I was purposely vague, as I still think you would be better off ignoring GBA/DS development for now, and focus on windows or linux development first. In this case, your compiler program would be different, and would probably be set up by your IDE.
#124437 - keldon - Thu Apr 05, 2007 11:57 pm
I think you should really start on something where you can press a 'n00b' button to compile; a n00b button to create a project; and so on. Then when you have got past the basic coding; you will be able to advance to more difficult ventures, like the GBA/DS hardware.
#124442 - beamer30 - Fri Apr 06, 2007 1:02 am
I've already made a number of simple prgrams thats why i want to start making gba and ds games.
ok guys im starting to get it alittle.(finally)
the source is on my desktop, but what do i do with
compile program? Do i have to put it with the source, and whats its command and how do i run it? Also where is the makefile that im supposed to put with the source? I'm making a ds program.
#124444 - tepples - Fri Apr 06, 2007 1:09 am
beamer30 wrote: |
I've already made a number of simple prgrams thats why i want to start making gba and ds games. |
In what language and with what compiler have you "already made a number of simple prgrams"?
Quote: |
the source is on my desktop, but what do i do with
compile program? Do i have to put it with the source, and whats its command and how do i run it? |
In general, the command is "make", which reads commands from the makefile that you should have copied into your project folder. The folders containing arm-eabi-gcc.exe and make.exe should be listed in the PATH environment variable. But have you ever used the command line of DOS, Windows, UNIX, or Linux before?
Do you know how to copy text in and out of a standard Command Prompt window?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124446 - beamer30 - Fri Apr 06, 2007 1:42 am
i made alot of simple "PROGRAMS" with python and some with mvbc++(microsoft visual basic C++)
yes i have and i know hoe to copy text from a command windo but not to it.
now im a little confused what do i even use gcc for and how?(i mean if i compile with makefile) what does the make.exe do and why do i need it)
i know the command is make, now im lost again. :( (not that a bad helper i think im just dumb)
edit:
i don't have a make.exe?
#124455 - tepples - Fri Apr 06, 2007 2:34 am
The ordinary sequence of events:
- Developer opens command interpreter.
- Developer opens a folder using the cd command.
- Developer types make and presses Enter.
- Command interpreter retrieves the PATH environment variable.
- Command interpreter searches all folders listed in PATH for a file named make.exe.
- Command interpreter finds make.exe in C:\devkitPro\msys\bin.
- Command interpreter tells the operating system to start the program C:\devkitPro\msys\bin\make.exe.
- Make reads a file called makefile in the current folder (which the developer chose in step 2).
- Makefile contains a list of what files are created from what files (e.g. an executable program is created from object code files, and object code files are created from source code files), and the commands needed to re-generate each file. For example, in the case of generating a .o file from a .c file or a .elf file from several .o files, the makefile specifies that the program arm-eabi-gcc.exe is to be used, with some set of options passed on the program's command line.
- For each file that needs to be created, Make calls the appropriate program. Make looks through the PATH, just as in steps 4 through 6, for these programs.
- Once the desired file specified by the makefile has been created, or once an error has occurred that prevents the file from being created, Make stops, and the command interpreter regains control.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124471 - beamer30 - Fri Apr 06, 2007 5:17 am
oh that makes way more sense!!!!!!!!!!!!!!
thank you so much this will probably be my last question:
how do you edit the makefile so it know what type of game to make,(gba or nds) and so it knows which file to use frome the source?(the code i made saved as cpp)
#124503 - tepples - Fri Apr 06, 2007 12:14 pm
beamer30 wrote: |
how do you edit the makefile so it know what type of game to make,(gba or nds) |
That's complicated. The command to tell the linker what platform you're going for is -specs. But you have to give different -I commands to arm-eabi-gcc when compiling and different -L commands when linking to tell it to look for libnds instead of libgba, and you have to add post-processing steps (padbin, gbafix, and optionally add a GBFS or FCSR file for GBA; ndstool for DS). Usually, you just start from an existing makefile that is already for the GBA or DS.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#124506 - gmiller - Fri Apr 06, 2007 12:52 pm
The makefile is just text so the same editor you use to edit your source code you can use to edit your makefile. The contents of a makefile have a syntax that is different from from any language you probably have ever seen.
Makefiles are built around defining dependencies. Generally your executable will be dependent on the object files. The object files will be dependent on source files.
For example: To build an executable called junk which in dependent on the object files One.o and two.o where One.o is compiled from One.c/One.h/Common.h and Two.o is compiled from Two.c / Two.h / Common.h the following makefile might be used.
Code: |
# Define where things can be found
I = ../inc/
L = ../lib/
B = ../bin/
# Define common include files
includes = $(I)Common.h
#first label (default build target) so "make" does this or "make all"
all : $(B)junk
@ echo "Default Build Complete"
#"make ultraclean" does this
ultraclean: clean
rm -f $(B)junk
rm -f depends.d
@ echo "Done"
#"make clean" does this
clean:
rm -f junk.o
rm -f One.o
rm -f Two.o
@ echo "Done"
#junk is dependent on One and Two
$(B)junk : One.o Two.o
$(CC) -o $@ One.o Two.o $(LLFLAGS)
#Above: link One.o and Two.o to produce $@ (label for this rule $(B)junk)
# rule to convert a .c to a .o
.c.o :
$(CC) -c $(CCFLAGS) -I $(I) $*.c
#One.o is dependent on One.c, One.h and the common includes in $(includes)
One.o : One.c One.h $(includes)
# same for Two
Two.o : Two.c Two.h $(includes)
# scan the source and build any other source dependencies
depends.d : One.c One.h Two.c Two.h $(includes)
gcc -MM -I ../inc One.c Two.c >depends.d
#include the dependencies automatically built from the source in the
# previous step.
include depends.d
|
This makefile when given to "make" will cause "make" to generate a list of dependencies and see what has changed. If the object file was created after the .c then the object file does not need to be rebuilt but if the .c or .h files were modified after the object file then the object file need to be rebuilt. Since each part has a dependency the makefile can examine each part determine if it need to be rebuilt and do the work. Since each part that is rebuilt can cause other parts to be rebuilt it can become a complex task but "make" has been designed to do this.
The only subtitle part of make files is that the labels need to start all the way to the left and any steps for that label must be tabbed in not spaced over. The steps terminate on the first line that does not have a tab as the first character.
This example is not very generic but does show what needs to be done is a very simple fashion. This example will not generate a GBA or DS executable. I did not use them as examples because the makefiles tend to be a little more complex and I was trying to be simple and concise here.
#124533 - beamer30 - Fri Apr 06, 2007 5:30 pm
ok well after you've made the make file what do you save it as
edit:
wait i think i figured it out, when you save a makefile you don't save it with any extenstions right its just saved as: all files.(or file, no extensions)
#124549 - gmiller - Fri Apr 06, 2007 8:29 pm
By default the GNU version of "make" looks for "GNUmakefile", "makefile" or "Makefile" in that order.
#124550 - beamer30 - Fri Apr 06, 2007 8:40 pm
hey i can't get any demo files to compile heres the error they come up with
Code: |
make: arm-elf-g++ command not found
make: *** [arm7_main.o] error 127 |
edit:
heres the whole thing if you need it
Code: |
C:\Documents and Settings\Game Wizard\Desktop\keys_demo1>make
arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ff
ast-math -mthumb-interwork -I/c/devkitPro/libnds/include -DARM7 -c arm7_main.cpp
-oarm7_main.o
make: arm-elf-g++: Command not found
make: *** [arm7_main.o] Error 127
C:\Documents and Settings\Game Wizard\Desktop\keys_demo1> |
Last edited by beamer30 on Fri Apr 06, 2007 8:44 pm; edited 1 time in total
#124551 - chuckstudios - Fri Apr 06, 2007 8:42 pm
It can't find the compiler. Are your environment variables set up correctly?
#124552 - beamer30 - Fri Apr 06, 2007 8:47 pm
sorry to sound so newbish, but its the code from a tut.
So i have no clue what enviorment variables are (not that far yet i guess)
what are they and where do i find them?
#124561 - keldon - Fri Apr 06, 2007 10:08 pm
Huh? Download the DevkitPro Installer; run; environment variables are set and the template makefiles work!
This is why it has been suggested to get started on something like Visual Studio / DevCPP etc. Look at all these things where you are stuck and don't know what what is! There are like 100 steps before you have a finished project, and each of them you have no knowledge of. It would be much more useful to get used to some other things, read up on some obvious stuff instead of asking to be spoon-fed.
Wikipedia and google are great places to get information. In google type "makefile wikipedia", or "wikipedia compiler" etc.
#124566 - beamer30 - Fri Apr 06, 2007 11:11 pm
ok man i wasn't trying to be spoon fed thanks for all the help guys and keldon read you sig lol.
Quote: |
smart people aren't those who give all the right answers, but those who ask all the right questions |
#124568 - keldon - Fri Apr 06, 2007 11:24 pm
Well as long as you soon can get to a point where you can create an environment to develop in at will before you lose interest it should be okay. But remember that google is your friend, often when you have a question you only need to put it into google.
You only need to put, "what are environment variables into google to see what I mean. Add wikipedia to your search parameters and you are very likely to have the information you want!
#124569 - beamer30 - Fri Apr 06, 2007 11:31 pm
lol i think i might have found the problem when i extract devkitpro after im finished do i have to install devkitarm and the msys package? if so im so stupid
#124570 - keldon - Fri Apr 06, 2007 11:41 pm
Okay, first of all a lot of people make the mistake of downloading the link from the page's news updates/blog. You should go to the download page and download the Windows Installer
- http://sourceforge.net/project/showfiles.php?group_id=114505&package_id=160396
The other download requires more advance steps and is NOT for the beginner (or anyone who has to ask questions).
#124571 - beamer30 - Sat Apr 07, 2007 12:02 am
ya i downloaded that one i just can't seem to get the makefiles to work heres the files from the tut maybe you guys can fiure out whats wrong.
arm7_main
Code: |
/*
keys_demo1 ARM7 Code
Chris Double (chris.double@double.co.nz)
http://www.double.co.nz/nintendo_ds
*/
#include <nds.h>
//////////////////////////////////////////////////////////////////////
#define TOUCH_CAL_X1 (*(vs16*)0x027FFCD8)
#define TOUCH_CAL_Y1 (*(vs16*)0x027FFCDA)
#define TOUCH_CAL_X2 (*(vs16*)0x027FFCDE)
#define TOUCH_CAL_Y2 (*(vs16*)0x027FFCE0)
#define SCREEN_WIDTH 256
#define SCREEN_HEIGHT 192
s32 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1;
s32 TOUCH_HEIGHT = TOUCH_CAL_Y2 - TOUCH_CAL_Y1;
s32 TOUCH_OFFSET_X = ( ((SCREEN_WIDTH -60) * TOUCH_CAL_X1) / TOUCH_WIDTH ) - 28;
s32 TOUCH_OFFSET_Y = ( ((SCREEN_HEIGHT-60) * TOUCH_CAL_Y1) / TOUCH_HEIGHT ) - 28;
//////////////////////////////////////////////////////////////////////
void startSound(int sampleRate, const void* data, uint32 bytes, u8 channel=0, u8 vol=0x7F, u8 pan=63, u8 format=0) {
SCHANNEL_TIMER(channel) = SOUND_FREQ(sampleRate);
SCHANNEL_SOURCE(channel) = (uint32)data;
SCHANNEL_LENGTH(channel) = bytes;
SCHANNEL_CR(channel) = SOUND_ENABLE | SOUND_ONE_SHOT | SOUND_VOL(vol) | SOUND_PAN(pan) | (format==1?SOUND_8BIT:SOUND_16BIT);
}
s8 getFreeSoundChannel() {
for (int i=0; i<16; i++) {
if ( (SCHANNEL_CR(i) & SOUND_ENABLE) == 0 ) return i;
}
return -1;
}
//////////////////////////////////////////////////////////////////////
void InterruptHandler(void) {
static int heartbeat = 0;
if (REG_IF & IRQ_VBLANK) {
uint16 but=0, x=0, y=0, xpx=0, ypx=0, z1=0, z2=0, batt=0, aux=0;
int t1=0, t2=0;
uint32 temp=0;
uint8 ct[sizeof(IPC->curtime)];
// Update the heartbeat
heartbeat++;
// Read the X/Y buttons and the /PENIRQ line
but = REG_KEYXY;
if (!(but & 0x40)) {
// Read the touch screen
x = touchRead(TSC_MEASURE_X);
y = touchRead(TSC_MEASURE_Y);
xpx = ( ((SCREEN_WIDTH -60) * x) / TOUCH_WIDTH ) - TOUCH_OFFSET_X;
ypx = ( ((SCREEN_HEIGHT-60) * y) / TOUCH_HEIGHT ) - TOUCH_OFFSET_Y;
z1 = touchRead(TSC_MEASURE_Z1);
z2 = touchRead(TSC_MEASURE_Z2);
}
batt = touchRead(TSC_MEASURE_BATTERY);
aux = touchRead(TSC_MEASURE_AUX);
// Read the time
rtcGetTime((uint8 *)ct);
BCDToInteger((uint8 *)&(ct[1]), 7);
// Read the temperature
temp = touchReadTemperature(&t1, &t2);
// Update the IPC struct
IPC->heartbeat = heartbeat;
IPC->buttons = but;
IPC->touchX = x;
IPC->touchY = y;
IPC->touchXpx = xpx;
IPC->touchYpx = ypx;
IPC->touchZ1 = z1;
IPC->touchZ2 = z2;
IPC->battery = batt;
IPC->aux = aux;
for(u32 i=0; i<sizeof(ct); i++) {
IPC->curtime[i] = ct[i];
}
IPC->temperature = temp;
IPC->tdiode1 = t1;
IPC->tdiode2 = t2;
//sound code :)
TransferSound *snd = IPC->soundData;
IPC->soundData = 0;
if (snd) {
for (int i=0; i<snd->count; i++) {
s8 chan = getFreeSoundChannel();
if (chan >= 0) {
startSound(snd->data[i].rate, snd->data[i].data, snd->data[i].len, chan, snd->data[i].vol, snd->data[i].pan, snd->data[i].format);
}
}
}
}
// Acknowledge interrupts
REG_IF = REG_IF;
}
//////////////////////////////////////////////////////////////////////
int main(int argc, char ** argv) {
// Reset the clock if needed
rtcReset();
//enable sound
SOUND_CR = SCHANNEL_ENABLE | SOUND_VOL(0x7F);
IPC->soundData = 0;
// Set up the interrupt handler
REG_IME = 0;
IRQ_HANDLER = &InterruptHandler;
REG_IE = IRQ_VBLANK;
REG_IF = ~0;
DISP_SR = DISP_VBLANK_IRQ;
REG_IME = 1;
// Keep the ARM7 out of main RAM
while (1) swiWaitForVBlank();
return 0;
}
//////////////////////////////////////////////////////////////////////
|
arm9_main
Code: |
/*
keys_demo1 ARM9 Code
Chris Double (chris.double@double.co.nz)
http://www.double.co.nz/nintendo_ds
*/
#include <nds.h>
static int old_x = 0;
static int old_y = 0;
static int shape_x = 0;
static int shape_y = 0;
static int shape_width = 10;
static int shape_height = 10;
static uint16 shape_color = RGB15(31, 0, 0);
void draw_shape(int x, int y, uint16* buffer, uint16 color)
{
buffer += y * SCREEN_WIDTH + x;
for(int i = 0; i < shape_height; ++i) {
uint16* line = buffer + (SCREEN_WIDTH * i);
for(int j = 0; j < shape_width; ++j) {
*line++ = color;
}
}
}
void on_irq()
{
if(REG_IF & IRQ_VBLANK) {
draw_shape(old_x, old_y, VRAM_A, RGB15(0, 0, 0));
draw_shape(shape_x, shape_y, VRAM_A, shape_color);
// Tell the DS we handled the VBLANK interrupt
VBLANK_INTR_WAIT_FLAGS |= IRQ_VBLANK;
REG_IF |= IRQ_VBLANK;
}
else {
// Ignore all other interrupts
REG_IF = REG_IF;
}
}
void InitInterruptHandler()
{
REG_IME = 0;
IRQ_HANDLER = on_irq;
REG_IE = IRQ_VBLANK;
REG_IF = ~0;
DISP_SR = DISP_VBLANK_IRQ;
REG_IME = 1;
}
int main(void)
{
powerON(POWER_ALL);
videoSetMode(MODE_FB0);
vramSetBankA(VRAM_A_LCD);
InitInterruptHandler();
while(1) {
old_x = shape_x;
old_y = shape_y;
// Read the register containing the data of which
// keys have been pressed.
uint16 keysPressed = ~(REG_KEYINPUT);
uint16 specialKeysPressed = ~IPC->buttons;
// Based on the key pressed, move the shape.
if(keysPressed & KEY_UP)
--shape_y;
if(keysPressed & KEY_DOWN)
++shape_y;
if(keysPressed & KEY_LEFT)
--shape_x;
if(keysPressed & KEY_RIGHT)
++shape_x;
// Change the color of the shape if the relevant key was pressed.
if(keysPressed & KEY_A)
shape_color = RGB15(31, 0, 0);
if(keysPressed & KEY_B)
shape_color = RGB15(0, 31, 0);
if(keysPressed & KEY_SELECT)
shape_color = RGB15(0, 0, 31);
if(keysPressed & KEY_START)
shape_color = RGB15(31, 31, 31);
if(keysPressed & KEY_R)
shape_color = RGB15(15, 0, 15);
if(keysPressed & KEY_L)
shape_color = RGB15(7, 15, 7);
// Y Key
if(specialKeysPressed & (1 << 1))
shape_color = RGB15(7, 7, 7);
// X Key
if(specialKeysPressed & (1 << 0))
shape_color = RGB15(0, 15, 15);
// Pen Down
if(specialKeysPressed & (1 << 6))
shape_color = RGB15(0, 31, 31);
// Hinge closed
if(!(specialKeysPressed & (1 << 7)))
shape_color = RGB15(0, 0, 0);
// Make sure the shape stays within the correct bounds of the
// screen.
if(shape_x + shape_width >= SCREEN_WIDTH)
shape_x = 0;
else if(shape_x < 0)
shape_x = SCREEN_WIDTH - shape_width - 1;
if(shape_y + shape_height >= SCREEN_HEIGHT)
shape_y = 0;
else if(shape_y < 0)
shape_y = SCREEN_HEIGHT - shape_height - 1;
swiWaitForVBlank();
}
return 0;
} |
and finaly heres the makefile code
Code: |
# Makefile for keys_demo1.nds
# chris.double@double.co.nz
NDSLIB_INCLUDE=$(DEVKITPRO)/libnds/include
NDSLIB_LIB=$(DEVKITPRO)/libnds/lib
all: keys_demo1.nds.gba
arm-eabi-gcc -g -c -Wall -O3 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb -mthumb-interwork -Ic:/devkitPro/libgba/include characters.c -o characters.o
arm7_main.o: arm7_main.cpp
arm-elf-g++ -g -Wall -O2 -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM7 -c arm7_main.cpp -oarm7_main.o
arm7.elf: arm7_main.o
arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm7.specs arm7_main.o -L$(NDSLIB_LIB) -lnds7 -oarm7.elf
arm7.bin: arm7.elf
arm-elf-objcopy -O binary arm7.elf arm7.bin
arm9_main.o: arm9_main.cpp
arm-elf-g++ -g -Wall -O2 -mcpu=arm9tdmi -mtune=arm9tdmi -fomit-frame-pointer -ffast-math -mthumb-interwork -I$(NDSLIB_INCLUDE) -DARM9 -c arm9_main.cpp -oarm9_main.o
arm9.elf: arm9_main.o
arm-elf-g++ -g -mthumb-interwork -mno-fpu -specs=ds_arm9.specs arm9_main.o -L$(NDSLIB_LIB) -lnds9 -o arm9.elf
arm9.bin: arm9.elf
arm-elf-objcopy -O binary arm9.elf arm9.bin
keys_demo1.nds: arm7.bin arm9.bin
ndstool -c keys_demo1.nds -9 arm9.bin -7 arm7.bin
keys_demo1.nds.gba: keys_demo1.nds
dsbuild keys_demo1.nds -o keys_demo1.nds.gba
clean:
rm -f *.bin
rm -f *.elf
rm -f *.o
rm -f *~ |
what am i doing wrong?
#124573 - keldon - Sat Apr 07, 2007 12:11 am
Maybe you are trying to do too much at once. The first thing you *should* try to do is compile an empty program. Let's see...
#1: Run Start\All Programs\DevkitPro\MSys
- MinGW32 window will open
#2: type "make" [Enter] into the MinGW32 command line
- MinGW32 should reply with, "make: *** No targets specified ..... Stop"
If you cannot find MSys then nobody can help you. If you did not get that reply from #2 then you have serious issues with *something*.
I wrote a small introduction to programming years ago. Run through that up to chapter 6, try to seek answers as opposed to simply asking questions. Bottom line is that in programming you are writing a set of instructions for the processor to follow; if you fail to be able to follow instructions then how do you expect to be able to specify them?
p.s. let me know if that link is ever broken as we are changing servers sometime soon and I may need to upload that again.
#124577 - beamer30 - Sat Apr 07, 2007 12:48 am
yes i was able to get into msys and ill go through your tut right now, also that program i posted was from another tut so maybe its just the tut?
edit:i went through your tut and it helped some what, but i bumped into another problem. i open MSys then change it to the path, and type make but it still says no makefile is found. Also should i be using msys to "make" all my files because i was using windows command line before so maybe thats why they weren't compileing? 1 more thing i could just be stting the path wrong is this the code to set the path?
Code: |
set Path="your path here"
|
#124623 - keldon - Sat Apr 07, 2007 10:06 am
Makefile's should be called "Makefile". DevkitPro has some examples; devkitPro\examples. Yes, compile everything in msys.
Use the tonc gba tutorials; although as we have been saying you would be best off with learning c++ in windows. The reason for this is that you will not be able to follow c++ tutorials with console development; so you will be asking many many more questions and soon will become a big inconvenience.
#124634 - gmiller - Sat Apr 07, 2007 1:20 pm
yes ....
#124711 - beamer30 - Sat Apr 07, 2007 10:47 pm
hey guys i finally fixed the compiler and it turns out the tut was just old so thanks for all the help because of you guys i was able to start compiling and running my programs yay!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!