Hacking DS2 Plugin Linker

Stormwave

Well-Known Member
OP
Member
Joined
Apr 22, 2010
Messages
237
Trophies
0
Website
Visit site
XP
229
Country
As requested, I've created a program to allow you to create a customised NDS Linker.

This program will allow you to create an NDS file that will automatically load another, user specified, NDS file. This *should* allow plugins that require a specific path to run from to be run from there original location as plugins.

This is version 0.3b, I haven't fully tested it by any means. Any testing is welcome. I don't know if this only works with homebrew or if it works with ROMs aswell, I haven't tested that yet.

Download DS2 Plugin Linker

The usage can obviously be expanded out of it's created scope. you can use it to link programs into any homebrew loader (EOS, MoonShell2 etc).

Changelog:

0.3b - Fixed a critical bug causing the FAT initialization to fail
0.3 - Completely changed the way it works.
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
Nice first attempt, I've had a (very) quick try - but, as usual with first attempts a couple of things to note
  • > Nothing is mentioned on what you can type into the PC Program
    Putting in JUST the nds name & you HAVE to have the original nds file in the ROOT.
    [I'm guessing IF we type in something like '/homebrew/colors.nds' then we can have 'colors.nds' in the /homebrew/ folder]

    > I've tried it with 4-5 homebrew (left in the root) - all worked EXCEPT 'amplituDS'.
    (It loaded up to the 'splash screen' but locked up (I guess it the way it's been programmed or something, & not to do with the linker.nds)
    Also tried a ROM (Bomberman.nds - also in root) - didn't work

    > BUG - You can't seem to be able to do multiple 'linker.nds' in one sitting.
    You need to shut down the program & restart it, otherwise you get an error stating it can't find 'Loader.dat',
    This is because it is looking for it in the folder you last saved the linker.nds to (i.e. 'x:\_dstwoplug\loader.Dat')

    > SUGGESTION - instead of the PC program to create the linker.nds - could we have a 'default' linker.nds file that looks at the name it been called, then read the corresponding ini file in the same directory which points to where the real nds file is stored. Or would this be to difficult ???

    e.g.
    • Lets say we rename 'linker.nds' to 'colors.nds' & put it into the /_dstwoplug/ folder
      When starting the linker, it sees it was called 'colors' so it looks for the file 'colors.ini' in the same directory
      Once found it then looks for a line like 'nds=' in the ini file
      It take the contents after the '=' (something like '/homebrew/colors.nds') & uses that to run the real nds
    This way people with something like 'DSOrganise' can edit the plugin ini without having to go to a PC to make a new 'linker.nds' each time
 

Stormwave

Well-Known Member
OP
Member
Joined
Apr 22, 2010
Messages
237
Trophies
0
Website
Visit site
XP
229
Country
Thanks for the feedback, I'll fix the bug asap.

As for your suggestion, as far as I am aware it isn't possible. NDS programs have no arguments passed to them at all, unless from specific loaders, therefore it is impossible the NDS file to detect it's own name unfortunately, hence the reason I made the program work in this way.
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
Awww..... what a shame, still it's better than nothing then (unless some other way can be thought of
laugh.gif
)
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
jurassicplayer said:
Why not just use Xenon++'s NDSLink? It does almost the exact same thing, only it redirects using either moonshell2 or the fake moonshell2 folder he provided.So can you explain how we would use that as a plugin. I though ndslink was a moonshell specific program

QUOTE(spinal_cord @ Aug 27 2010, 11:37 PM) I'm about 95% sure that my iMenu (unreleased so far) sends the program path and filename when loading an nds file.

If someone can suggest a specific homebrew that requires this, I will test it.
I think why this was originally suggested was so that people could place their homebrew in their own folders instead of being 'forced ' to use dstwoplug. If iMenu can launch homebrew that's in a different folder than the plugin one I don't think it matters

Onto another idea for THIS linker.
Instead of the pc program telling the linker.nds where the original is stored, how about it telling the linker what line to look for in a linker.ini

We can copy the linker file over,
rename it to whatever we like (eg 'link1.nds'),
it will use 'link1.ini' for the program name & icon,
when run it will look in 'linker.ini' for the line we told it when using the pc prog e.g. 'link1=',
and use the path to run the original
 

Xenon++

Taiju Yamada
Member
Joined
Dec 17, 2009
Messages
1,394
Trophies
0
Website
Visit site
XP
107
Country
CannonFoddr said:
So can you explain how we would use that as a plugin. I though ndslink was a moonshell specific program
1. get mshl2tools_r31.7z/reset_mse/reset.mse
2. put mshl2tools_r31.7z/reset_mse/mselink/mselink.exe to the same folder
3. type "mselink reset.mse /folder/target.nds link.nds"
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
Xenon++ said:
So how can the NDS know "I'm link1.nds"? Without ARGV support it is impossible.Well I know that TextDS2 (made by Stormwave BTW) originaly needed a PC program that altered part of the textDS actual code (i.e a type of HEX Edit) to tell the nds where to look for the accompanying textDS.ini file. My idea is just a variation of it (In fact your 'mselink' seems to be doing a similar thing as what the PC program did)
----------
I'll try & explain it better now (last post was through my phone & I was a little rushed)

What I was suggesting is that we have a 'blank' linker.nds file that we use a PC program to HexEdit part of it to look for a particular line in a linker.ini file,
that means that that particular version of 'linker.nds' will ONLY LOOK for that line in the ini & it doesn't matter WHAT we call it.
- as long as we give it a typical DS2 plugin ini/bmp of the same name, the DS2 will use the info in that ini for the title & icon

But when the program is run - it will look for the line that was HexEdited in it, then load the program mentioned in the line
This means we can have numerous renamed 'linker.nds' files (with a bmp/ini of the same name for the DS2 to use) & one 'linker.ini' file which ALL the 'linker.nds' will use, & yet can be edited on the DS (via programs like DSorganise) or PC (via Notepad etc)

example:
Let's say we HexEdit a 'linker.nds' to look for 'Link1='
We copy it to the '/_dstwoplug/ folder and rename it to 'tester1.nds' (in fact it can be called whatever we like - since it's hacked to ONLY look for 'Link1=')
We include a 'tester1.bmp' and a 'tester1.ini' file in the '/_dstwoplug/' folder as well
  • The 'tester1.ini' contains
    Code:
    [plug setting]
    icon=fat1:/_dstwoplug/tester1.bmp
    name=DSColors
    meaning the graphic 'tester1.bmp' will be shown with the title of 'DSColors' from within the DS2 plugin menu
When you run 'DSColors' (or 'tester1.nds') it would then look for 'Line1=' in 'linker.ini' file (also in '/_dstwoplug/ folder')
  • The 'linker.ini file would have multiple lines in it like
    CODE[Linker Paths]
    Link1=/HBApps/colors.nds
    Link2=/HBGame/vghero.nds
    Link3=/HBUtils/Savbackup.nds
It will 'see' that 'Link1=/HBApps/colors' - so that's the program it will run

We then could have a second 'linker.nds' that been hacked for 'Link2=', but that would load '/HBGame/vghero.nds' instead; 3rd linker.nds hacked to 'Link3=' & so on

If there's a 'Link=' line that doesn't have a hacked 'linker.nds' in the plugin folder - then it's simply ignored
If there's a hacked 'linker.nds' but no 'Link=' line - then up pops an error like 'Linkpath does not exist in Linker.ini'

AFAIK - this won't need any of this ARGV stuff involved - you just need to remember which hacked 'linker.nds' is used for which 'link=' line - hence in my earlier post I suggested 'Link1.nds' would be the one hacked to look @ 'Link1=', 'Link2.nds' @ 'Link2=' etc etc

Hope that makes it a little clearer to what I meant
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
riverchen said:
Is it possible to have a linker that opens up DS_GAME then autoboots it to my /homebrew/ folder?
I don't think so - from what I've read in other posts the DSTwo doesn't have an 'autoboot' facility, which is what I think you are asking for - although I'm sure spinal_cord will know much more than I do about DS2 methods, especially as he been working on an alternative plugin menu
 

Stormwave

Well-Known Member
OP
Member
Joined
Apr 22, 2010
Messages
237
Trophies
0
Website
Visit site
XP
229
Country
Your suggestion of multiple lines is certainly possible CannonFoddr. I might well use that concept in the next implementation. I suppose it will make it easier for people to change directories etc a bit easier. I'll probably do that in the next couple of days.

As for the autoboot thing, afaik it would be extremely difficult, but not strictly impossible. It's quite outside my original perceived scope of this project, but I'll look into it, just don't get your hopes up
wink.gif
 

riverchen

Well-Known Member
Member
Joined
Sep 27, 2009
Messages
405
Trophies
0
XP
157
Country
United States
Stormwave said:
Your suggestion of multiple lines is certainly possible CannonFoddr. I might well use that concept in the next implementation. I suppose it will make it easier for people to change directories etc a bit easier. I'll probably do that in the next couple of days.

As for the autoboot thing, afaik it would be extremely difficult, but not strictly impossible. It's quite outside my original perceived scope of this project, but I'll look into it, just don't get your hopes up
wink.gif


OH GOD YEA YOU WILL BE MY GOD IF YOU MAKE THIS.
 

Stormwave

Well-Known Member
OP
Member
Joined
Apr 22, 2010
Messages
237
Trophies
0
Website
Visit site
XP
229
Country
Done and done.

Download version 0.3 for the updates.

You can now create a "linker.ini" file in your _dstwoplug folder, this is seperated by numbered tags like so:

[link 1]
file=fat:/test/test.nds

[link 2]
file=fat:/test2/test2.nds

[link 3]
file=fat:/_dstwo/DSGAME.nds
autoboot=fat1:/HOMEBREW/

[link 4]
file=fat:/_dstwo/DSGAME.nds
autoboot=fat1:/NDS/FAVOURITES/NULL.nds

Autoboot allows you to choose a path to boot into if you are loading DSGAME.nds. Note that it has to be "fat1:/" rather than "fat:/". I have had some issues setting it up correctly, and you may need to enter a null filename to get it to work i.e. "autoboot=fat:/HOMEBREW/null.nds". It was quite a bit easier than I thought, since DSGAME already stores the last used directory. The loader simple overwrites the lastsave.ini file with a new path.

To boot them use the DS Plugin Linker to create a loader, enter the link number you want to use and click "create". Save it where you want, and it should work fine.

I think the limit is about 999 links.

I know it's a bit tricky to use and my explanation is crap (way too tired atm, hehe). Any questions ask in here.
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
I've given 0.3 a try - slight problem has arisen... It doesn't seem to work now
cry.gif


Every Homebrew I try comes up with 'Init'ing FAT... fail!'
[link 1]
file=fat:/Homebrew/VideoGamesHero.nds

[link 2]
file=fat:/Homebrew/Colors.nds

[link 3]
file=fat:/Homebrew/dsvideo.nds

[link 4]
file=fat:/Homebrew/PlantsVsZombies.nds

[link 5]
file=fat:/Homebrew/pocketphysics.nds

[link 6]
file=fat:/Homebrew/stillaliveds.nds

[link 7]
file=fat:/Homebrew/UAPaint.nds
As you can see all of the programs are in '/Homebrew/' folder on the root, & just as a tryout I even changed 'file=fat:/' to 'file=fat1:/' & it's still the same error message.

Further info - although I doubt it actually matters - is that I changed the linker.nds name to the name of the program it's associated with so the 'linker.nds' that was set to '1' it was renamed as 'VideoGamesHero.nds', so that it also used the ini/bmp of the plugin
I even tried setting the linker.nds as 'Link 1' and 'link 1' with the PC program - but that didn't work either,
and I even DLDI'd the programs in the /Homebrew/ folder as well - just in case... That didn't work either

On a side note - but I guess it depends on how hard it is to program - I think I'd prefer it if the linker.ini was arranged more like
Code:
[Links]
Link1=fat:/Homebrew/VideoGamesHero.nds
Link2=fat:/Homebrew/Colors.nds
Link3=fat:/Homebrew/dsvideo.nds
 

Stormwave

Well-Known Member
OP
Member
Joined
Apr 22, 2010
Messages
237
Trophies
0
Website
Visit site
XP
229
Country
QUOTE said:
I think [Dir Info] will just allow to show the folder, not autoboot.

Aye, that is what it is meant to do. I should have been more specific, I presume that this is what riverchen wanted it to do.

QUOTE said:
Every Homebrew I try comes up with 'Init'ing FAT... fail!'
[link 1]
file=fat:/Homebrew/VideoGamesHero.nds

Thats not good, heh. As far as I am aware I didn't change the fat initialising at all, so it's strange that it's failing. Filenames won't make any difference on that, so I've no idea what the problem is :/

It is a problem with the linker, not the homebrew that it's attempting to load. Are you DLDI patching the linker NDS files? (You shouldn't need to, but it might help. Or maybe don't DLDI patch them if you are)

QUOTE
On a side note - but I guess it depends on how hard it is to program - I think I'd prefer it if the linker.ini was arranged more like
Aye, I programmed it this way so you can add multiple options for links though. For example the autoboot thing (and anything else it might be able to do in the future).
 

CannonFoddr

Regular GBATemp Lurker
Member
Joined
Sep 23, 2006
Messages
4,134
Trophies
1
Age
56
Location
Sitting by computer
Website
www.youtube.com
XP
1,287
Country
Stormwave said:
Are you DLDI patching the linker NDS files? Nope I didn't DLDI the linker originally - but I just tried it & still no good

I've even tried putting linker.ini into root & removed 'fat:/' from the path - still no good

QUOTE said:
On a side note - but I guess it depends on how hard it is to program - I think I'd prefer it if the linker.ini was arranged more likeQUOTE
Aye, I programmed it this way so you can add multiple options for links though. For example the autoboot thing (and anything else it might be able to do in the future).
Ah!! - didn't think of that......... Doh !!!
 

Xenon++

Taiju Yamada
Member
Joined
Dec 17, 2009
Messages
1,394
Trophies
0
Website
Visit site
XP
107
Country
Stormwave said:
Aye, that is what it is meant to do. I should have been more specific, I presume that this is what riverchen wanted it to do.

It is a problem with the linker, not the homebrew that it's attempting to load. Are you DLDI patching the linker NDS files? (You shouldn't need to, but it might help. Or maybe don't DLDI patch them if you are)
1. Well if you have many files on that directory, searching might be difficult (well riverchen just want to show homebrew folder so it is OK though)
2. How do you apply DLDI? Well bootlib will do that automatically... Is your patching bootlib is OK?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: Lol Veho.