#139578 - bocca - Fri Sep 07, 2007 6:30 pm
This one is for gurus, I think :D
I am writing a piece of homebrew to load files contained in the .nds file itself using NitroROM file system (http://nocash.emubase.de/gbatek.htm#dscartridgenitroromfilesystem), similar to GBFS or PALib FS. I own a slot2 flashcart (M3 Lite), with it I can easily access the files through GBA Slot ROM memory address (08000000h). It also works on desmume, dualis and no$gba emulators.
I would like to extend this to work with slot1 flashcards (M3 simply, R4, G6, X-treme), but I do not own one. I know I can use libfat/DLDI instead, but now I would like to know if it is technically possible. I assume it can be done, since backup ROMs loaded from slot2 can access ROM data. But I dont know how.
I have read that the NDS Slot ROM is not mapped to ARM9/ARM7 bus, so my code would not work. Instead, it must be accessed through a complex serial protocol with encryption(http://nocash.emubase.de/gbatek.htm#dscartridgeprotocol). Do slot1 flashcards mimic that protocol, so that I can use the B7aaaaaaaa000000h command to read data? Is there an easy way?
Related to this, I wonder how slot2 flashcarts achieve to execute NDS ROMs that access ROM data. I've noted that a .nds ROM patched by M3 Game manager is almost 99% binary different from the original (only first 4000h are equal). Does the patch replace the calls to the card protocol with access to 08000000h? It sounds too complicated...
Thanks in advance
#139588 - truedream - Fri Sep 07, 2007 8:32 pm
bocca wrote: |
This one is for gurus, I think :D
I am writing a piece of homebrew to load files contained in the .nds file itself using NitroROM file system (http://nocash.emubase.de/gbatek.htm#dscartridgenitroromfilesystem), similar to GBFS or PALib FS. I own a slot2 flashcart (M3 Lite), with it I can easily access the files through GBA Slot ROM memory address (08000000h). It also works on desmume, dualis and no$gba emulators.
I would like to extend this to work with slot1 flashcards (M3 simply, R4, G6, X-treme), but I do not own one. I know I can use libfat/DLDI instead, but now I would like to know if it is technically possible. I assume it can be done, since backup ROMs loaded from slot2 can access ROM data. But I dont know how.
I have read that the NDS Slot ROM is not mapped to ARM9/ARM7 bus, so my code would not work. Instead, it must be accessed through a complex serial protocol with encryption(http://nocash.emubase.de/gbatek.htm#dscartridgeprotocol). Do slot1 flashcards mimic that protocol, so that I can use the B7aaaaaaaa000000h command to read data? Is there an easy way?
Related to this, I wonder how slot2 flashcarts achieve to execute NDS ROMs that access ROM data. I've noted that a .nds ROM patched by M3 Game manager is almost 99% binary different from the original (only first 4000h are equal). Does the patch replace the calls to the card protocol with access to 08000000h? It sounds too complicated...
Thanks in advance |
this is only possible with cards that support "TRUE NO PATCH MODE"
cards that use patching like R4-M3 will not work
on ez5 and acekard and some other cards the B7 command will work
properly as the hardware emulates it correctly
alternativly if you insert code into your app that gets patched by
R4 then you can use it R4 too ;)
#139598 - nornagon - Sat Sep 08, 2007 12:23 am
You don't need to know this, because you don't pirate games. Or do you?
#139599 - Lick - Sat Sep 08, 2007 12:49 am
Are you trying to load a Slot-1 game, or from a Slot-1 device?
If it's the latter, just use libfat to load the .NDS file. Libfat will handle the card protocol.
_________________
http://licklick.wordpress.com
#139601 - bocca - Sat Sep 08, 2007 1:32 am
nornagon wrote: |
You don't need to know this, because you don't pirate games. Or do you? |
Lick wrote: |
Are you trying to load a Slot-1 game, or from a Slot-1 device?
If it's the latter, just use libfat to load the .NDS file. Libfat will handle the card protocol. |
I just want to make my homebrew program work on slot-1 devices with no additional data files (libfat), only the .nds file (NitroROM). I need only read-access to resources (sound, graphics, etc.) just like commercial ROMs.
truedream wrote: |
this is only possible with cards that support "TRUE NO PATCH MODE"
cards that use patching like R4-M3 will not work
alternativly if you insert code into your app that gets patched by
R4 then you can use it R4 too ;) |
What is "TRUE NO PATCH MODE"? I've read that M3 Simply and R4 Revolution does not need patching. Do you mean that these devices do a patch at load time or something like that? How can I make my code be pached by R4?
If the B7 command works for slot-1 devices and GBAROM works for slot-2 devices, I'll try to detect the device type at runtime (for example, comparing the NDS Slot ROM header with the one in 027FFE00h) to use the proper read method.
#139608 - tepples - Sat Sep 08, 2007 2:44 am
bocca wrote: |
I just want to make my homebrew program work on slot-1 devices with no additional data files (libfat), only the .nds file (NitroROM). I need only read-access to resources (sound, graphics, etc.) just like commercial ROMs. |
To work around the lack of an initial working directory in libfat, you can scan the file system using EFS.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#139610 - chishm - Sat Sep 08, 2007 3:15 am
All SLOT-2 and most SLOT-1 cards that run commercial warez do so by patching certain DS card functions in the games to load using that card's protocol instead. Those DS card functions are found only because they are the same across all games that use the same version of the SDK.
If you want this to work on your app, you'd need to use the same functions as commercial games do, that is, you'd need to use the SDK. Since this is illegal without being an official developer, you can't actually do this. So your app would only work on cards that support the card protocol in hardware. You'll limit your audience to a small small segment of the homebrew community for the sake of packing your data into the NDS. That being said, look for EFS.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#139622 - truedream - Sat Sep 08, 2007 9:14 am
chishm wrote: |
All SLOT-2 and most SLOT-1 cards that run commercial warez do so by patching certain DS card functions in the games to load using that card's protocol instead. Those DS card functions are found only because they are the same across all games that use the same version of the SDK.
If you want this to work on your app, you'd need to use the same functions as commercial games do, that is, you'd need to use the SDK. Since this is illegal without being an official developer, you can't actually do this. So your app would only work on cards that support the card protocol in hardware. You'll limit your audience to a small small segment of the homebrew community for the sake of packing your data into the NDS. That being said, look for EFS. |
wrong. some cards R4/M3 etc need patching.
some do not - those what do support the correct hardware commands
the patching by R4 etc is done transparentl to the
user but it is defenetly done.
#139623 - chishm - Sat Sep 08, 2007 10:11 am
Uh, re-read what I wrote. I said "most SLOT-1 cards". Out of all the SLOT-1 cards available on the market, only a small minority have hardware support for the DS card protocol as used in commercial games. That may change in future, but as of now it is correct.
Also, as I said, cards that do patching look for functions specific to the official Nintendo SDK. Those that patch homebrew on-the-fly either use DLDI (R4/M3) or directly patch libfat (old versions of the DS-Xtreme firmware).
truedream, next time you reply make sure you actually read what you are replying to.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com
#139626 - Diddl - Sat Sep 08, 2007 10:34 am
but it would be cool to support same protocoll like commercial roms do (Nitro FS) for homebrew.
Which slot 1 cards supports this protocol directly without patching? Is there a list of slot 1 cards which can do this?
I think such a slot 1 flashcard will need
+ a 'intelligent' card with own cpu which does the protocoll
+ or you need to have a big flash memory (same as commercial) and load nds file into it bevore starting it?
#139631 - truedream - Sat Sep 08, 2007 1:39 pm
chishm wrote: |
Uh, re-read what I wrote. I said "most SLOT-1 cards". Out of all the SLOT-1 cards available on the market, only a small minority have hardware support for the DS card protocol as used in commercial games. That may change in future, but as of now it is correct.
Also, as I said, cards that do patching look for functions specific to the official Nintendo SDK. Those that patch homebrew on-the-fly either use DLDI (R4/M3) or directly patch libfat (old versions of the DS-Xtreme firmware).
truedream, next time you reply make sure you actually read what you are replying to. |
eh, i did read ALL .. <> slot-2
so yes, sure this is correct what you said most is appropriate.
#139647 - M3d10n - Sat Sep 08, 2007 3:54 pm
Use EFSLib:
http://forum.gbadev.org/viewtopic.php?t=13195&highlight=efslib
It allows you to use NitroFS, keeping all your data files inside the .NDS itself. It works by using libfat and scanning the card to find the .NDS itself, reads the embedded filesystem so you can use efs_* IO functions to read files from inside the NDS.
I just can't get it working on nocash no matter what (in theory, using FCSR and appending the .NDS to itself should work).
#139655 - bocca - Sat Sep 08, 2007 5:25 pm
Thank you so much to all of you. Your responses are clarifying. I'll have a look to EFS.
#139657 - bocca - Sat Sep 08, 2007 6:04 pm
It would be interesting to extend EFS to avoid DLDI usage if possible (for read-only access):
- If it detects that direct access to 08000000h memory address is possible (checking the header against 027FFE00h), then use it. This way, in theory all slot-2 devices, in particular old slot-2 non-fat devices (neoflash?) will work without DLDI.
- If not, if it detects that card protocol can be used (checking the header against 027FFE00h), then use it. This way new slot-1 devices with card protocol emulation (EZV?) will also work without DLDI.
- In the rest of the cases (the middle), DLDI will be used. If the device supports DLDI auto-pathing, no user intervention is needed. Only in other cases the user should patch the file.
#139663 - chuckstudios - Sat Sep 08, 2007 7:23 pm
I think using DLDI universally is the best solution. Having the program figure out how it should run itself is kind of stupid when there's one universal way.
#139665 - truedream - Sat Sep 08, 2007 7:49 pm
chuckstudios wrote: |
I think using DLDI universally is the best solution. Having the program figure out how it should run itself is kind of stupid when there's one universal way. |
actually the no - the DLDI method would need to find the file on sd-card based on unique signature, for 4GB sd-card this may take a while ;)
#139688 - chuckstudios - Sat Sep 08, 2007 10:17 pm
But it only needs to happen once :P
Once EFSlib finds the signature, it writes the path inside the NDS. I would know since I use it in my software.
#139718 - truedream - Sun Sep 09, 2007 7:58 am
chuckstudios wrote: |
But it only needs to happen once :P
Once EFSlib finds the signature, it writes the path inside the NDS. I would know since I use it in my software. |
ha, well yes, that nice trick, it locates itself and modifies itself to reloc itself quickly, yes that really nice.
actually a very smart directory search would possible find the nds also quick if it caches dir and fat and then only looks for one sector from the nds file
#139720 - Lick - Sun Sep 09, 2007 12:17 pm
I've written a Locator function (improved by melw) that can search for both a directories and files. So you can statically name your directory to something like "HelloWorld" and let it contain your files, or statically name your NDS to "HelloWorld.nds". Doesn't have to be on the root.
_________________
http://licklick.wordpress.com
#139741 - HyperHacker - Sun Sep 09, 2007 6:30 pm
That's awesome, why haven't I seen it before? You could use it with self-modification to only have to find the config file once.
_________________
I'm a PSP hacker now, but I still <3 DS.