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 > PersonalData handlers? and time on DS

#109856 - jefklak - Tue Nov 21, 2006 8:26 pm

Hello,


I'm trying to retrieve two simple variables from the libnds package, but the damn thing just won't work at all...
First of all, I'd like the profile name of the current DS - stored in the tPERSONAL_DATA struct (see http://devkitpro.sourceforge.net/devkitProWiki/libnds/a00026.html ). In system.h, there's a define

Code:
#define    PersonalData   ((PERSONAL_DATA*)0x27FFC80)


but PersonalData->name or so doesn't work. How do I retrieve the name field?

Secondly, I'd simply like to get the current time. Including <time.h> etc gives me a ridiculus value, and the RealTimeClock nds example simply does something like "IPC->rtc_hours". This is always 0 when I try to use it, but I did test Watch.nds and that works on my DS Lite. Do you need to initialize something or so before accessing IPC->rtc_x? I almost copied all code in the RTC example but all I get are a couple of zero values...
Edit: this does NOT work
http://forum.gbadev.org/viewtopic.php?t=5487&highlight=clock

Code:

iprintf("%s %i %i\n", IPC->rtc_month, IPC->rtc_day, IPC->rtc_year + 2000);
iprintf("time %2d-%02d-20%02d  %2d:%02d:%02d\n", IPC->curtime[3], IPC->curtime[2], IPC->curtime[1], IPC->curtime[5], IPC->curtime[0], IPC->curtime[4]);


All 0? what the hell?


Thanks a lot for any help!
Greets

#109859 - Lick - Tue Nov 21, 2006 8:46 pm

The 'name' variable is 2byte per character (instead of 1byte). Just use [0, 2, 4, 6...] and ignore [1, 3, 5...], this works for ASCII strings.

The RTC works on hardware and No$gba. If you want something like time(), check out my NDSX_time.
_________________
http://licklick.wordpress.com

#109860 - jefklak - Tue Nov 21, 2006 8:57 pm

I'm testing on actual hardware! It refuses to work :(


The name refuses to work too, I tried this

Code:
    char name[11] = {0};
    for(int i=0; i<PersonalData->nameLen; i++)
        name[i] = (char)(PersonalData->name[i] & 255); // get ascii-bits from utf-16 name
    printf("Hi %s,\n", name);


and this gives "Hi {NULL}". Meh?
Your code does not work either since it's also using IPC->x
Do you need to enable something special in the Makefile?

#109864 - jefklak - Tue Nov 21, 2006 10:34 pm

okay it works now, I had to wrap everything to ARM7... weird!
(well, the name works, I still need to fix the clock)

#109865 - Lick - Tue Nov 21, 2006 10:43 pm

You actually need to increase i by 2 instead of ++, so you SKIP the second byte.

jefklak wrote:
okay it works now, I had to wrap everything to ARM7... weird!
(well, the name works, I still need to fix the clock)

Wrap everything to ARM7?
_________________
http://licklick.wordpress.com

#109866 - Lazy1 - Tue Nov 21, 2006 10:55 pm

The default arm7 binary should do everything your looking for already, just use ndstool without the -7 option.

#109886 - jefklak - Wed Nov 22, 2006 9:58 am

Lick wrote:
You actually need to increase i by 2 instead of ++, so you SKIP the second byte.

jefklak wrote:
okay it works now, I had to wrap everything to ARM7... weird!
(well, the name works, I still need to fix the clock)

Wrap everything to ARM7?


In the ARM9 code (main stuff), add a getName identifier to the Fifo queue. In ARM7, call and empty and return nameLen and name.

#109918 - Lick - Wed Nov 22, 2006 9:50 pm

You should really post your code. There's a huge bug somewhere.
_________________
http://licklick.wordpress.com