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 > File printing for log

#145054 - Shay - Sun Nov 11, 2007 1:45 am

Hi all

Would you know how to print in an external file for log ?
fwrite does not seem to work...

Thank you

#145055 - Lick - Sun Nov 11, 2007 2:02 am

Did you initialize libfat? Without libfat, standard file I/O functions will not work on the DS.
_________________
http://licklick.wordpress.com

#145056 - Shay - Sun Nov 11, 2007 2:08 am

Yes I initialized libfat

Here is the code to print :
Code:

FILE *f = fopen(fileName_.c_str(), "wb");
fwrite("<?xml version=\"1.0\" encoding=\"utf-16\"?>", sizeof(char) * 40, 1, f);
fclose(f);


But the file remains empty... :(

#145063 - Lick - Sun Nov 11, 2007 3:53 am

You're testing on an emulator or actual hardware? AFAIK, none of the existing emulators have implemented *reliable* file output. Try running on real hardware (don't forget to DLDI-patch your binaries!).
_________________
http://licklick.wordpress.com

#145065 - Shay - Sun Nov 11, 2007 4:00 am

I try on emulator for now.

Thank you

#145068 - dantheman - Sun Nov 11, 2007 4:11 am

Which emulator are you using? Some have support for DLDI or libfat while others don't.

#145098 - shash - Sun Nov 11, 2007 5:07 pm

As of now, no emulator flushes the emulated FAT memory back to the host file-system, so writing to it won't have any effect.
_________________
http://shashemudev.blogspot.com

#145100 - HyperHacker - Sun Nov 11, 2007 5:17 pm

Does it persist across resets, though? You could write the file, then reset and use DSOrganize to read it.
_________________
I'm a PSP hacker now, but I still <3 DS.

#145164 - shash - Mon Nov 12, 2007 2:04 am

Afaik, all the emulators (desmume does it that way) seem to reset the FAT emulated buffer when loading a game/app from HD, as they create the emulated FAT system only from the source folder.
_________________
http://shashemudev.blogspot.com

#145176 - HyperHacker - Mon Nov 12, 2007 4:58 am

What if you just hit reset without loading another ROM? You could dump the file to the screen at startup.

Also, No$GBA supports debug logging.
_________________
I'm a PSP hacker now, but I still <3 DS.

#145190 - shash - Mon Nov 12, 2007 11:47 am

HyperHacker wrote:
What if you just hit reset without loading another ROM? You could dump the file to the screen at startup.


Well, I guess that would be feasible, but probably too much of a hack :P

HyperHacker wrote:
Also, No$GBA supports debug logging.


That's a way better solution, implementing some sort of log port seems better :)
_________________
http://shashemudev.blogspot.com