#161452 - monocasa - Mon Aug 04, 2008 3:13 am
So, I'm in the process of writing a library for reading from the embedded filesystem in .nds rom images. But, I've ran into an issue reading on real hardware (it works on all of th emulators that I've tried). When reading from the card (and being loaded from an R4) all I get is the same hex string (017047C2F5FFFFEA00009FE51EFF2FE1 for the first sixteen bytes at least). All of my reads thus far are just the File Allocation Table and File Name Table, so I don't think that its an encryption issue (though I could be quite wrong). Are there any special hoops that I have to jump through to read off an R4? Am I even right thinking that the R4 is my problem?
Gratci, in advance.
#161453 - tepples - Mon Aug 04, 2008 4:12 am
Have you just tried opening the .nds file using libfat and reading the NitroFS that way?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#161457 - Dwedit - Mon Aug 04, 2008 4:32 am
I don't think the R4 even attempts to simulate the actual DS card communication protocol beyond booting initially. After it boots, it just uses some custom protocol to read and write sectors.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#161458 - monocasa - Mon Aug 04, 2008 4:39 am
Dwedit wrote: |
I don't think the R4 even attempts to simulate the actual DS card communication protocol beyond booting initially. After it boots, it just uses some custom protocol to read and write sectors. |
Well, it has to do at least the stuff included in the .nds, or else commercial games wouldn't work on it (and they wouldn't be getting sued).
#161459 - monocasa - Mon Aug 04, 2008 4:55 am
tepples wrote: |
Have you just tried opening the .nds file using libfat and reading the NitroFS that way? |
Are you saying reading the .nds through libfat (and it directly reading the fat filesystem on the sd card), or does libfat have a way to read from the NitroFS directly from the currently being run?
#161465 - josath - Mon Aug 04, 2008 4:32 pm
monocasa wrote: |
Dwedit wrote: | I don't think the R4 even attempts to simulate the actual DS card communication protocol beyond booting initially. After it boots, it just uses some custom protocol to read and write sectors. |
Well, it has to do at least the stuff included in the .nds, or else commercial games wouldn't work on it (and they wouldn't be getting sued). |
Unfortunately, they don't emulate an actual game cart. They modify the commercial games to use their custom protocol. Really the only way you can write code that will work on all flashcarts is to use libnds. (Not counting a few really old flashcarts, and a few old slot-2 GBA flashcarts)
monocasa wrote: |
tepples wrote: | Have you just tried opening the .nds file using libfat and reading the NitroFS that way? |
Are you saying reading the .nds through libfat (and it directly reading the fat filesystem on the sd card), or does libfat have a way to read from the NitroFS directly from the currently being run? |
Yes, the idea is basically:
Code: |
fatInitDefault();
FILE *nds = fopen("mygame.nds", "r");
// read NDS header
// fseek to nitroFS start
// read needed data from nitroFS
|
One issue is finding mygame.nds in the first place. EFS does some crazy hacks to automatically find it, that work in most cases and is not terribly inefficient. There is "argv support" coming Real Soon Now(TM) to libnds/devkitarm, with the downside that this code will also need to be added to the various homebrew loaders.