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 I/O for loading graphics and audio resources?

#145114 - Natso - Sun Nov 11, 2007 7:54 pm

I'm trying to figure out whether or not the following are possible, so I can know what kind of limits I'm facing (it's for what is possibly my next project).

Loading files from the flash cartridge's filesystem... Are there any good examples or tutorials where I can see/learn the proccess?

Also, how much trouble would it be to load an mp3 format song, presumably lower quality, but... buffering it from the flashcart's filesystem in real-time... has this been done before? Or is it at all reasonable?

Tracker files, in s3m or similar format... (also streaming them from the filesystem) I imagine it would be more efficient than streaming the mp3, but if there are some quirks I should know about, can you give me details?

Lastly, loading graphics from the filesystem. I really only need to load them at predetermined intervals (never at the same time that music is playing). Basically it is for re-skinning the GUI. Is there a common image format that would be reasonable to use, or should I just have the user convert it into a ds-friendly format before putting it on the cartridge?

Thanks!
- Natso
_________________
I'm a bomb technitian. If you see me running, try to keep up ;)

#145117 - tepples - Sun Nov 11, 2007 8:17 pm

Natso wrote:
I'm trying to figure out whether or not the following are possible, so I can know what kind of limits I'm facing (it's for what is possibly my next project).

Loading files from the flash cartridge's filesystem... Are there any good examples or tutorials where I can see/learn the proccess?

It's called libfat.

Quote:
Also, how much trouble would it be to load an mp3 format song, presumably lower quality, but... buffering it from the flashcart's filesystem in real-time... has this been done before?

MoonShell does it, and so does DSOrganize.

Quote:
Tracker files, in s3m or similar format

MoonShell 1.6 and earlier did it, and DSOrganize still does.

Quote:
Lastly, loading graphics from the filesystem. I really only need to load them at predetermined intervals (never at the same time that music is playing). Basically it is for re-skinning the GUI. Is there a common image format that would be reasonable to use, or should I just have the user convert it into a ds-friendly format before putting it on the cartridge?

It shouldn't be too much of a problem to load .bmp or .tga files from the file system and convert them to the format that the DS video hardware wants. But you will have to tell the user whether to use 16-color, 256-color, or high- or true-color images.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#145150 - HyperHacker - Mon Nov 12, 2007 12:39 am

tepples wrote:
But you will have to tell the user whether to use 16-color, 256-color, or high- or true-color images.
Or you can just check the file header to see which type it is. No reason you can't support more than one colour depth. (You'd probably want to point out, though, that using the same bit depth as the program uses will be faster - less conversion required - and anything above 16-bit will have to be downsampled to 16-bit anyway.)
_________________
I'm a PSP hacker now, but I still <3 DS.

#145161 - Lick - Mon Nov 12, 2007 1:11 am

If you use high- or true-color images, you'll need to convert the pixelvalues back to R5G5B5(A1) to display them on the DS screen. The problem is that it's rather ugly with most of your images. A solution would be implementing dithering. Noise dithering is really simple and relatively fast. Diffuse dithering is a bit more complicated.

I use the free DepthDither 2.0 for the not-free Photoshop to convert images to 15-bit "offline".
_________________
http://licklick.wordpress.com

#145173 - tepples - Mon Nov 12, 2007 3:09 am

HyperHacker wrote:
No reason you can't support more than one colour depth. (You'd probably want to point out, though, that using the same bit depth as the program uses will be faster - less conversion required - and anything above 16-bit will have to be downsampled to 16-bit anyway.)

So if a DS program is expecting a 16-color image where color index 0 is transparent, and the user passes a 24-bit image, which library should the DS program use to dither the image to 15 non-FF00FF colors? Or should all reskinnable GUIs operate in 16-bit mode?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#145175 - HyperHacker - Mon Nov 12, 2007 4:57 am

That's entirely up to you. ;-)
_________________
I'm a PSP hacker now, but I still <3 DS.