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.

DS development > new to ds

#61009 - ProblemBaby - Wed Nov 16, 2005 6:50 pm

Hello

Iam new to nds but ive coded gba for a while and since nds is quite different Ive to ask some questions, it will probably more:), but I will stick to this for now!

1. as far as Ive understood the arm7 is only used for things like wifi, touchscreen, sound etc.. not the actual game, is it correct? or is it often you have parallel game loops where arm7 updates the player, arm9 update the enemies etc...?

2. Iam such that I want to do everything myself and fully understand it. Ive only found one tutorial and that one is using ndslib, is there any tutorial out there that takes evrything from scratch? Iam just looking for some basics.

3. I read at the compo rules, that the standard makefiles makes the binary contains debug info or something like that, which flag tells it to do that, or what flag should be added to not add it?

Thanks in advance!

#61013 - Joat - Wed Nov 16, 2005 7:19 pm

Official developers aren't allowed to change the code running on the arm7, and the official bin takes care of things like playing audio, send/recv wifi packets, polling the touch and x/y buttons, etc...

On homebrew, you're welcome to do as much as you want (until you run out of time) on the arm7, but most people treat it as a black box that plays sound and returns touch screen coords. Writing, testing, and debugging single-CPU code is almost always easier. Some programs use it to do more on the sound side, like implementing a module decoder or SPC700 emulator on it, but I don't know of anyone doing game or render logic on the arm7.

Doing everything yourself is certainly doable, but there are even different levels of that:
  • You can start completly from scratch and write your own crt0 and link script, or even compile and retarget GCC from source (really not reccomended)
  • You can use just the crtls (crt0, linkscript) from devkitpro, but write your own header files / library.
  • You can use just the crtls (crt0, linkscript) and register defines from libnds, calling no library functions and not using the default arm7 stub (a lot of people code this way)

If you don't know what a linkscript is, or how badly borked the arm-thumb-fpu-etc... flags in the object file spec are, you do not want to do the first option. For the second option, the wiki (http://www.bottledlight.com/ds) has information on most of the hardware except 2d/3d/vram management (which will eventually show up).

There aren't really any tutorials on how to write a new library from scratch (since there really is only one library, and we add code to it rather than write why we added code to it), but if you're concerned about libnds being MFC or something, don't be. It's a fairly low-level library that doesn't abstract away much (perhaps too little, in fact).

Also, all of the source code for libnds is available, so if you want to understand everything, you can take a look at code that uses it, and the look at the functions it calls, to see what is going on inside (usually just a few register writes, hardware-polling, bit-banged serial code, or 3D math, depending on where you're looking).
_________________
Joat
http://www.bottledlight.com

#61016 - dovoto - Wed Nov 16, 2005 7:33 pm

Just to add a bit to that, libnds (with the exception of a few of the 3d functions and some of the console printing functionality) is nothing more than register definitions and thier bit fields and the occasional wrapper functions that do nothing more than write those bits to the registers (even much of the 3D functionality is attained using little more than wrappers).

I am in the process of wrapping most register calls so the user does not have to set the registers directly...this is mainly to make changes in the library less painful and to help those people who use intelisence enabled IDEs (functions generaly resolve better than defines). Also this allows us to automate our library documentation.

Even if you do not plan on using the library I still recomend you grab it; the source and examples should be a good starting point for learning how the hardware works.
_________________
www.drunkencoders.com

#61021 - ProblemBaby - Wed Nov 16, 2005 8:01 pm

Interesting I had no idea about the offical bin, is it somehow possible to get it from a commercial cassette?, do you have any ideas how its structured?
Great link, exactly what I was looking for, registers and flags!

Nice that libnds was open-source, I didnt thought so, I will check some things out. But I'll still try to write the most myself, I love to make my own systems, but of course libnds will be a great reference.

Thanks for the fast replies!

#61095 - cybereality - Thu Nov 17, 2005 7:19 am

If youre new to ds coding you probably want to start with chris doubles tutorials which use libnds. I know how it is to want to code everything from scratch, but sometimes there is no use in reinventing the wheel. Libnds really is a great library and is pretty barebones as it is. You would want to at least learn how everyone else is doing it before you make improvements.
_________________
// cybereality