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 > help with drunken-coders' tutorials and DSi

#174639 - cyberant - Sun Jul 04, 2010 11:48 am

I've been trying to follow drunken coders' tutorial at dev-scene, and I have some problems and questions.

I have a DSi with AceKard 2i and I've been trying to run certain hombrew demo files. it seems that some demo files won't run perfectly with the DSi or won't run at all (or they run but make the DS shut down soon after running).

I tried following Day1 tutorial, writing the code below and building is with "make":
Code:
#include <nds.h>
#include <stdio.h>
 
int main(void)
{
   int i;
 
   consoleDemoInit();
 
   videoSetMode(MODE_FB0);
 
   vramSetBankA(VRAM_A_LCD);
 
   printf("Hello World!\n");
   printf("www.Drunkencoders.com");
 
   for(i = 0; i < 256 * 192; i++)
      VRAM_A[i] = RGB15(31,0,0);
 
   swiWaitForVBlank();
 
   return 0;
}


If I run it with an emulator it runs fine, showing the text message. But, when I try running it on a DSi it shuts the DS off (it seems to show the text message for a split-second).

1) Is there a problem with the code?
2) Or should the code be updated to work properly on a DSi?
3) Is there a way to make it work properly on both a DSi and a normal DS?
4) Are there any other things I should take notice of if I want my code to be compatible for all available DS consoles?

Also I'd like to mention that when I tried building and running the Hello_World example that comes with the devkitpro it seems to work perfectly on my DSi:
Code:
/*---------------------------------------------------------------------------------

   $Id: main.cpp,v 1.13 2008-12-02 20:21:20 dovoto Exp $

   Simple console print demo
   -- dovoto


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

#include <stdio.h>

volatile int frame = 0;

//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
   frame++;
}
   
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
   touchPosition touchXY;

   irqSet(IRQ_VBLANK, Vblank);

   consoleDemoInit();

   iprintf("      Hello DS dev'rs\n");
   iprintf("     \x1b[32mwww.devkitpro.org\n");
   iprintf("   \x1b[32;1mwww.drunkencoders.com\x1b[39m");
 
   while(1) {
   
      swiWaitForVBlank();
      touchRead(&touchXY);

      // print at using ansi escape sequence \x1b[line;columnH
      iprintf("\x1b[10;0HFrame = %d",frame);
      iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px);
      iprintf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py);      
   
   }

   return 0;
}


Your help is appreciated.

#174641 - Sektor - Sun Jul 04, 2010 12:32 pm

It's not a problem with the DSi, it would do the same on any DS. It's a problem with the code. Some tutorials were written when the devkit compiled code used to hang on a return 0 but now it tries to return to menu and if it can't, it shuts the DS down.

Now if you want an infinite loop then code an infinite loop instead of doing a return.
_________________
GTAMP.com/DS

#174642 - cyberant - Sun Jul 04, 2010 12:51 pm

Sektor wrote:
It's not a problem with the DSi, it would do the same on any DS. It's a problem with the code. Some tutorials were written when the devkit compiled code used to hang on a return 0 but now it tries to return to menu and if it can't, it shuts the DS down.

Now if you want an infinite loop then code an infinite loop instead of doing a return.
Thanks! :)
I changed the code and wrapped swiWaitForVBlank with a while(true) loop and it works.

Also, thanks for confirming that it's not a problems with the DSi hardware.