#163078 - darkchild - Sun Sep 21, 2008 10:24 pm
Is it possible to print onscreen which DLDI device the NDS Rom is patched for?
if so, how?
#163080 - silent_code - Sun Sep 21, 2008 10:39 pm
Yes, it is. There's an identifier of some sort and an API function that returns it, iIrc. Please search the forum.
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.
#163081 - AntonioND - Sun Sep 21, 2008 10:43 pm
Take a look at this:
http://chishm.drunkencoders.com/libfat/index.html
Quote: |
stat
The stat information of a file includes some useful information.
The st_ino field contains the start cluster number of the file, which can be passed to NDSMP.
The st_dev field contains a unique identifier for the inserted device. For example, for a file openned on the GBAMP CF, the st_dev has a value of 0x4643504D. This is 'MPCF' if placed in a string. |
#163082 - darkchild - Sun Sep 21, 2008 11:28 pm
can you give me an example?
#163098 - AntonioND - Mon Sep 22, 2008 3:12 pm
darkchild wrote: |
can you give me an example? |
Code: |
#include <dir.h>
#include <unistd.h>
struct stat st;
char filename[MAXPATHLEN];
DIR_ITER* dir;
dir = diropen ("/");
if (dir == NULL)
iprintf ("Unable to open the directory.\n");
else if (dirnext(dir, filename, &st) == 0)
iprintf ("Device: %s\n", st.st_dev);
else iprintf ("Didn't find any file.\n");
|
I haven't tested it, but it should work.
#163102 - darkchild - Mon Sep 22, 2008 4:26 pm
My DS shows a black screen when I print the device name :X
on the emulator (DeSmuME It shows nothing :X)
edit:
ST_DEV returns an integer..
That's why it crashed..
Last edited by darkchild on Mon Sep 22, 2008 4:35 pm; edited 1 time in total
#163103 - AntonioND - Mon Sep 22, 2008 4:27 pm
darkchild wrote: |
My DS shows a black screen when I print the device name :X
on the emulator (DeSmuME It shows nothing :X) |
Try with %d instead of %s.
#163104 - darkchild - Mon Sep 22, 2008 4:35 pm
as I found out XD it now only shows a number, but what can I do with this number?
#163106 - thoduv - Mon Sep 22, 2008 5:09 pm
Code: |
iprintf ("Device: %c%c%c%c\n", (st.st_dev>>24)&0xff,(st.st_dev>>16)&0xff,(st.st_dev>>8)&0xff,(st.st_dev)&0xff); |
#163109 - darkchild - Mon Sep 22, 2008 6:59 pm
can those "Calculations" be made into a final variable? (Char variable if possible)
edit:
got it working!
Code: |
char card[5];
card[3] = (st.st_dev>>24)&0xff;
card[2] = (st.st_dev>>16)&0xff;
card[1] = (st.st_dev>>8)&0xff;
card[0] = (st.st_dev)&0xff;
card[4] = '\0';
|
thanks :D
#163111 - josath - Mon Sep 22, 2008 8:17 pm
This should be a simpler way instead of the above calculation:
Code: |
char card[5];
memcpy(card, st.st_dev, 4);
card[4] = '\0'; |
#163114 - Maxxie - Mon Sep 22, 2008 8:58 pm
Code: |
char card[5] ;
snprintf(card,sizeof(card),"%s",&st.st_dev) ;
|
@josath, you would want to use the reference to the int for the memcpy instead of the int itself (cast to a pointer)
This should btw the reason for the crash in the first place. (ignoring the missing string termination)
_________________
Trying to bring more detail into understanding the wireless hardware