Homebrew Opening files on DS

ZukaZamam3e

Member
OP
Newcomer
Joined
Nov 12, 2015
Messages
9
Trophies
0
Age
32
XP
53
Country
United States
Hello,

I am having trouble and I hope someone can help. I'm new to DS development, but I have been through Game Development. The issue I have is trying to call fopen on a file for my DS Game. It can't locate the file. Now I think the issue is with the nds file not carrying my file, which is an image, inside of it. Is my Makefile supposed to capture it and put it in the nds file? Any help on this would be great. I've been searching for a while and can't seem to find any solutions.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,412
Country
United Kingdom
There are three ways DS homebrew can read data
1) incbin style methods. Here it would be present either in source code or otherwise available at compile time. Not really used on the DS but used extensively on the GBA, though the GBA also had stuff like in 2) for homebrew purposes.
2) read from the internal filesystem. Homebrew mostly emulated the filesystem used by commercial games for this and used one of the same tools (ndstool) to manage this task.
3) DLDI to read files directly on the flash cart's SD card/CF card/NAND memory section... via a library called libfat, or if you are compiling a very old piece of homebrew it might still be gba_nds_fat.
http://chishm.drunkencoders.com/DLDI/ has some more.
Here you put files directly on the SD card in whatever directory you reckon you want to use. There was an attempt to get a convention going where homebrew devs would stick things in a certain directory rather than all using the root directory but it did not get far.

Most do not use it any more but you can also hybridise 2 and 3 to include a virtual filesystem at the end of the file (see FCSR). It was really only used for those without flash carts or emulators that can deal with DLDI.
 

ZukaZamam3e

Member
OP
Newcomer
Joined
Nov 12, 2015
Messages
9
Trophies
0
Age
32
XP
53
Country
United States
So if I were to go with number 2, would fopen see the file there in the nds file, or is there a specific function I would call from the nds.h. I understand how 3 would be easier, but I think 2 would give me a bit of a challenge and more work to do. Thank you for the help. I really appreciate it. I will be able to try this out tonight when I get home from work.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,412
Country
United Kingdom
I am not actually sure. DLDI pretty much took over and various GBA slot flash carts had trouble with 2) if the files got large, not to mention the ease of copying a file across vs messing with ndstool. Most homebrew I ever messed with was more for DLDI and even then it was just putting things in another directory if there was a collision between two pieces I wanted to use/just wanted to not have 50 directories and files on the root of my SD card and that usually involved just file/directory name changes and no need to pay attention to function names and call form.
 

ZukaZamam3e

Member
OP
Newcomer
Joined
Nov 12, 2015
Messages
9
Trophies
0
Age
32
XP
53
Country
United States
So I decided to go with libfat and it worked, for a moment. I bricked my acekard2i. It would work sometimes and not others. I tried the paper shim method and it didn't work so I ordered a new one. So my next question, is there a way I can test libfat with an emulator?
 

ZukaZamam3e

Member
OP
Newcomer
Joined
Nov 12, 2015
Messages
9
Trophies
0
Age
32
XP
53
Country
United States
Yea I think I wore out the card taking it out so many times. You are awesome for helping me. I really appreciate it. So I would just tell my gbs slot to point to that folder? Sorry I can't test it right now since I'm at work.
 

ZukaZamam3e

Member
OP
Newcomer
Joined
Nov 12, 2015
Messages
9
Trophies
0
Age
32
XP
53
Country
United States
So, DLDI doesn't seem to working on my desmume. I get an error saying, "Sorry.. right now you can't use the default (stream rom from disk) with homebrew due to a bug with DLDI-autopatching". My version of desmume is 0.911. Is there a certain version I need for libFat to work?
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,412
Country
United Kingdom
Quite possibly. I have not used desmume with DLDI for quite some time at this point. I used to use it often enough for screenshots and video capture of homebrew. I did a search for the message and it sent me to this thread and the source code

Code:
/*
	Copyright (C) 2006 yopyop
	Copyright (C) 2008-2015 DeSmuME team

	This file is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This file is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
*/


//for homebrew, try auto-patching DLDI. should be benign if there is no DLDI or if it fails
	if(gameInfo.isHomebrew())
	{
		if(!CommonSettings.loadToMemory)
			msgbox->warn("Sorry.. right now, you can't use the default (stream rom from disk) with homebrew due to a bug with DLDI-autopatching");
		if (slot1_GetCurrentType() == NDS_SLOT1_R4)
			DLDI::tryPatch((void*)gameInfo.romdata, gameInfo.romsize, 1);
		else
			if (slot2_GetCurrentType() == NDS_SLOT2_CFLASH)
				DLDI::tryPatch((void*)gameInfo.romdata, gameInfo.romsize, 0);

	}

It would seem there is then an option that you might want to check. Afraid I am not on a windows machine right now and the Linux Desmume builds are quite nerfed on the options front so I can not try things out. Somewhere in the options should be an emulate flash cart of some form.
 

ZukaZamam3e

Member
OP
Newcomer
Joined
Nov 12, 2015
Messages
9
Trophies
0
Age
32
XP
53
Country
United States
I changed the load to memory and it worked! You are a genius. Now I just have to get my quads to stop flickering and then I'm good. I'm pretty sure its the graphics card because it showed up fine on the Acekard. Thank you so much!
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    BigOnYa @ BigOnYa: That be sweet tho, xbox/gamepass games on the go would be nice