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 > Cannot build: undefined reference to `initSystem'

#143588 - Kheldar - Wed Oct 24, 2007 3:10 am

I've installed devkitpro and PALib again after reinstalling XP. However trying to build anything including any of the tutorials results in:

Quote:
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-eabi/4.1.2/../../../../arm-eabi/lib/th
umb/ds_arm9_crt0.o: In function `CIDLoop':
ds_arm9_crt0.s:(.init+0x2ac): undefined reference to `initSystem'
collect2: ld returned 1 exit status
make[1]: *** [/c/Lesson2/Lesson2.elf] Error 1


Have I forgotten to do something after installing? ><

Thanks.

#143590 - wintermute - Wed Oct 24, 2007 4:14 am

Isn't that just great?

It would appear that the PAlib people have done something rather nasty. Can you build the libnds examples provided with devkitARM?
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#143591 - Hyouko - Wed Oct 24, 2007 6:01 am

Nah, I got a similar bug after trying to manually install devkitARM r21 on my Vista machine. After the rest of the updates got out (and were installed by the updater prog) everything worked fine.

#143593 - wintermute - Wed Oct 24, 2007 6:23 am

Hyouko wrote:
Nah, I got a similar bug after trying to manually install devkitARM r21 on my Vista machine. After the rest of the updates got out (and were installed by the updater prog) everything worked fine.


With PAlib specifically?

I did hear a rumour that the PAlib people were actually embedding libnds now rather than working with the installed version. Hopefully it's not true

EDIT: Yes, it appears to be true. PAlib is really rather broken, sorry.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#143600 - Rajveer - Wed Oct 24, 2007 9:35 am

Hmm, seems I get a similar problem after using the automated installer on Vista 64 (w/o PALib). When trying to compile an example I get:

Quote:
C:\DSDevelopment\devkitPro\examples\nds\sound\SimpleSound\data>make
make: *** No targets specified and no makefile found. Stop.


After trying to compile my own project I get (after using build.bat which cleans and makes):

Quote:
C:\DSDevelopment\Raji\Futuracer\Futuracer7>make clean
make: *** [clean] Error 1

C:\DSDevelopment\Raji\Futuracer\Futuracer7>make
make: *** [build] Error 1

C:\DSDevelopment\Raji\Futuracer\Futuracer7>pause
Press any key to continue . . .


My environmental variables are:

Devkitarm: /c/DSDevelopment/devkitPro/devkitARM
Devkitpro: /c/DSDevelopment/devkitPro
Path: c:\DSDevelopment\devkitPro\msys\bin
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem

EDIT: Fixed, with the newer version compatible with Vista 64.

#143625 - Kheldar - Wed Oct 24, 2007 9:22 pm

wintermute wrote:
Isn't that just great?

It would appear that the PAlib people have done something rather nasty. Can you build the libnds examples provided with devkitARM?


Sorry for not replying sooner, long work hours. :)

I got the same error building those. However I just reinstalled devkit without PAlib and they build fine now. Is PAlib unusable with devkitpro now then?

I wanted to use PAlib as image loading was easier. I cant seem to grasp what you need to do for the file from the graphics examples and couldnt find anything that made sense searching around. Maybe I'm just being really dense.

For example in the 256 colour bitmap example there are .git and .grit files, I have the app, but cant seem to make my own .git and .grit files. Do I need these? The source has #include "drunkenlogo.h but I cant see that file anywhere?

Say I have a 256x256 bitmap. What should be done to it in what order with what tools to then use it in the code?

#143633 - Hyouko - Wed Oct 24, 2007 9:55 pm

Well, a kindly fellow named Peter linked me to his texture converting tool:

http://www.console-dev.de/tmp/tex2n3d.zip

which you can use to get .bin files for the texture and/or texture palette. you can then load them in the same way that the various example 3D nds projects (textured cube, paletted cube, etc) do.

#143640 - wintermute - Wed Oct 24, 2007 11:08 pm

Hyouko wrote:
Well, a kindly fellow named Peter linked me to his texture converting tool:


That's nice, shame it's not actually relevant to the OP's question.

Stay tuned, large post in progress, I'm doing my best to explain a specific use of grit in some detail but it may take a while to get done.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog


Last edited by wintermute on Thu Oct 25, 2007 6:06 am; edited 1 time in total

#143675 - wintermute - Thu Oct 25, 2007 6:06 am

Kheldar wrote:

Sorry for not replying sooner, long work hours. :)


That's OK, there's no particular rush.

Quote:

I got the same error building those. However I just reinstalled devkit without PAlib and they build fine now. Is PAlib unusable with devkitpro now then?


That's a bit disturbing, I'm hoping this was just a result of the timing of the updates rather than a specific PAlib related issue. Both libnds and devkitARM were updated simultaneously and you may have managed to run the updater at a point when libnds had not yet propagated through the sourceforge mirror system. The link error you were experiencing is due to having the older libnds version installed which does not contain some of the code needed by the toolchain itself.

From a recent cursory examination of the PAlib files it would appear that they have decided to distribute some random versions of the libraries supplied by devkitPro. This situation makes it extremely difficult to ensure that their system will work with any updates I make.

Quote:

I wanted to use PAlib as image loading was easier. I cant seem to grasp what you need to do for the file from the graphics examples and couldnt find anything that made sense searching around. Maybe I'm just being really dense.


Image loading seems easier because they've written the code for you and you don't have to understand the underlying architechture. It's great if you want the instant gratification of seeing stuff on screen but not so good when you get a bit more advanced and discover that it doesn't work in the right way for your latest game design.

Quote:

For example in the 256 colour bitmap example there are .git and .grit files, I have the app, but cant seem to make my own .git and .grit files. Do I need these? The source has #include "drunkenlogo.h but I cant see that file anywhere?


Sorry, it seems I didn't remove the old files from the examples before generating the archive. You only need a .grit file, .git was used before we had to rename the tool due to a name collision with a source control system.

Quote:

Say I have a 256x256 bitmap. What should be done to it in what order with what tools to then use it in the code?



It kind of depends on what you intend the bitmap for. Since you specified 256x256 here and that's the size of a small DS background map I'm going to assume you want to use a tiled background here.

The standard arm9 template supplied now has rules for converting images in a folder called 'gfx' using grit. This is a fairly simple procedure.

First copy the arm9 template found in devkitPro\examples\nds\templates - on my set up I just copied the arm9 folder from c:\devkitPro\examples\nds\templates to c:\projects\nds.

Then give the folder a new name, I renamed it as 256colorTilemap - that way I have some idea of what it is later when I'm looking through the code.

Make a new folder in there called gfx and copy your 256x256 256color bitmap in there.

Now double click the .pnproj file in the template folder to load the project in Programmer's Notepad 2. We're going to create a .grit file so that grit knows what format to convert the image to - this is a simple text file containing command line arguments for grit. I've commented the options here so you know what they are, the lines beginning with # are ignored by the tool. I'm using a file called tilemap.bmp so this text file is saved as tilemap.grit

Code:

#-------------------------------------------------------
# graphics in tile format
#-------------------------------------------------------
-gt

#-------------------------------------------------------
# tile reduction by tiles, palette and hflip/vflip
#-------------------------------------------------------
-mRtpf

#-------------------------------------------------------
# graphics bit depth is 8 (256 color)
#-------------------------------------------------------
-gB8

#-------------------------------------------------------
# map layout standard bg format
#-------------------------------------------------------
-mLs


A full list of the commands that grit understands can be found at http://coranac.com/files/grit-readme.txt

Now we need to write some code to display the image so open up the main.c file and edit it to suit. I ended up with this

Code:

/*---------------------------------------------------------------------------------

   Simple tilemap demo
   -- WinterMute

---------------------------------------------------------------------------------*/
#include <nds.h>

#include "tilemap.h"

//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------

   // initialise the interrupt system
   irqInit();
   // and enable the vblank interrupt so we can use swiWaitForVblank()
   irqEnable(IRQ_VBLANK);

   // enable the main screen with background 0 active
   videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE);

   // map bank A for use with the background
   vramSetBankA(VRAM_A_MAIN_BG);
 
   // enable background 0 in 256 color mode with a 256x256 map
   // BG_TILE_BASE changes the offset where tile data is stored
   // BG_MAP_BASE gives the offset to the map data
   BGCTRL[0] = BG_TILE_BASE(0) | BG_MAP_BASE(4) | BG_COLOR_256 | TEXTBG_SIZE_256x256;

   // use dma to copy the tile, map and palette data to VRAM
   // CHAR_BASE_BLOCK gives us the actual address of the tile data
   // SCREEN_BASE_BLOCK does the same thing for maps
   // these should match the BG_TILE_BASE and BG_MAP base numbers above
   dmaCopy(tilemapPal,BG_PALETTE,tilemapPalLen);
   dmaCopy(tilemapTiles,(void *)CHAR_BASE_BLOCK(0),tilemapTilesLen);
   dmaCopy(tilemapMap,(void *)SCREEN_BASE_BLOCK(4),tilemapMapLen);

   // finally, hang around in an infinite loop
   // using swiWaitForVBlank here puts the DS into a low power loop
   while(1) {
      swiWaitForVBlank();
   }

   return 0;
}


The header file "tilemap.h" is generated by grit and can be found in the build folder. The names are generated from the filename of the bmp so, for a tiled image like this we end up with a few variables defined.

<filename>Pal - address of the palette data
<filename>PalLen - size of the palette data in bytes
<filename>Tiles - address of the tile data
<filename>TilesLen - size of he tile data in bytes
<filename>Map - address of the map data
<filename>MapLen - size of the map in bytes

It's worth reviewing the material in TONC, http://coranac.com/tonc/text/regbg.htm covers tiled backgrounds in some detail. The documentation there is all for GBA but the DS implements a superset of the GBA hardware so it's still well worth reading.

For what it's worth I uploaded the complete project for this little example at http://devkitpro.sourceforge.net/256colorTilemap.zip
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog