#167629 - Emmanuel - Sat Mar 21, 2009 1:36 am
In C++...
So, I have my homebrew project... and code is all placed on RAM at startup... normally, with 4mb this is not much of an issue... but I want to add hundreds of characters as different as I can make them, so, they will use different code...
Now, I think this is solved by DLL... the objects of each Character are linked at runtime, and so, I only use the RAM when they are called...
But, I've heard DLL doesn't work on the DS... I guess due to a lack of an OS...
So, I need a way to load into ram ONLY the code for the characters, stages, items, input types, etc... that I will use... Why? Because we have plans to add lots of them... as most as we can, and we can add more in 2gb than in 4mb....
#167630 - Dwedit - Sat Mar 21, 2009 1:46 am
I think devkitarm allows you to use overlays, but only to a limited extent. Although they can have the correct location in memory, There is no built-in way to have the overlays separate from the binary so that the RAM is free.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#167631 - Emmanuel - Sat Mar 21, 2009 2:01 am
Dwedit wrote: |
I think devkitarm allows you to use overlays, but only to a limited extent. Although they can have the correct location in memory, There is no built-in way to have the overlays separate from the binary so that the RAM is free. |
Overlays require that I know the size right? In that case... C++ would not be useful... I'd had to convert to ASM right? o_o
So, I divide the program in Overlays... of a size calculated by the largest object of that type...
So, it would be in my case:
4 characters
1 Stage
X items at a time (unknown for now)
3 inputTypes most (Owner, CPU, and External Human -Ds to Ds comm-
I would need to set the starting places in RAM for those overlays, and load from the file system into that address
Right?
But, at linking time, how do I make it so the linker "links" the code without it being actually linked into the code (epic confusion: so the code knows the functions exist)
One example: Hypothetical
Loading for one character
My overlay is at RAM 0
I use a function to load the code into it... I guess through a pointer (can I even set a pointer manually? I know there's no OS to stop me though...)
So, with an If I decide which file to load...
And then, how do I tell my source the GeneralCharacter object source is there?
How would calling the functions from there go?
*Using C++, and virtual functions for the cases where they are different*
#167632 - nanou - Sat Mar 21, 2009 2:07 am
Whoa... do you really expect to exhaust 4MB with code? How complex is this character behavior? Surely there's going to be a lot of common code between them...
_________________
- nanou
#167633 - Emmanuel - Sat Mar 21, 2009 2:13 am
nanou wrote: |
Whoa... do you really expect to exhaust 4MB with code? How complex is this character behavior? Surely there's going to be a lot of common code between them... |
It's a SSB clone for the DS... sure, they have common code, but the specials are different... and we would like to add 100+
Stages are close to being completely the same though...
Items are all different...
And, if I keep adding stuff, this will pop-up.... and changing later once everything is done is harder....
#167634 - nanou - Sat Mar 21, 2009 2:27 am
Honestly I doubt that would take a significant amount of code in proportion to the engine. The engine should handle all the physics, and the character-specific code is basically small scripts that deal with animations and character states and whatnot. The scripts should be fairly small (there was a discussion here a while ago about rolling your own interpreters for that kind of thing.) You can even treat them as data, and load them in separately with no fussing with overlays.
_________________
- nanou
#167635 - Emmanuel - Sat Mar 21, 2009 2:38 am
nanou wrote: |
The scripts should be fairly small (there was a discussion here a while ago about rolling your own interpreters for that kind of thing.) You can even treat them as data, and load them in separately with no fussing with overlays. |
Well... I think I'll have to go with interpreting... or just keep going... and hope for the best....
Btw, how does DSLinux is? Can it run a game especifically designed for it as a normal DS game? Can it DLL? :P I'm stubborn... and it does seem like the easiest alternative...
#167637 - DiscoStew - Sat Mar 21, 2009 3:08 am
Think you could give a few examples that you believe require different sets of code? It's just my belief that in practically all situations, a generalized set of code that can do different stuff with different sets of data is overall better than having individual sets of code for every little thing.
_________________
DS - It's all about DiscoStew
#167638 - Emmanuel - Sat Mar 21, 2009 3:32 am
DiscoStew wrote: |
Think you could give a few examples that you believe require different sets of code? It's just my belief that in practically all situations, a generalized set of code that can do different stuff with different sets of data is overall better than having individual sets of code for every little thing. |
Umm... so far... nope... maybe just the Special attacks, but even those are similar...
Sometimes I'm just a bit too greedy on resources
#167640 - DiscoStew - Sat Mar 21, 2009 3:53 am
Heh, are you in that state of mind that you want to be prepared "if" things get a bit too different? :P
_________________
DS - It's all about DiscoStew
#167653 - hacker013 - Sat Mar 21, 2009 11:06 am
You can try to use DSLI (DS Library Interface) made by elhobbs
http://forum.gbadev.org/viewtopic.php?t=16119&postdays=0&postorder=asc&start=15
_________________
Website / Blog
Let the nds be with you.
#167674 - Emmanuel - Sat Mar 21, 2009 9:32 pm
It looks just like what I need... but... the file is no longer downloadable... too much time not being downloaded TT_TT
Do you have a copy?
#167689 - hacker013 - Sun Mar 22, 2009 11:55 am
Yes, I have posted a mirror in the other topic. I hope you can use it.
_________________
Website / Blog
Let the nds be with you.
#167719 - josath - Mon Mar 23, 2009 6:08 pm
Emmanuel wrote: |
It looks just like what I need... but... the file is no longer downloadable... too much time not being downloaded TT_TT
Do you have a copy? |
Don't use this. It's the wrong solution for you. You'll just be wasting your time and so on.
I really doubt you'll get anywhere close to 4mb of code, the majority of your space will be used up by data. If you really need lots of super complex moves by all your characters, then the next best thing to use would be simple scripts, as mentioned above. Or perhaps build a custom data format that describes how moves work.
As also mentioned before, if you find yourself repeating code over and over that is similar, but with small changes, then you should refactor that so it's not repeated, it will take up less space then.
But really, overlays, dynamic libraries, etc are just going to cause you a HUGE headache.
PS: another think hacker013 forgot to mention, is that DLSI is GPL, meaning if you use it, you would be required to release all your code as GPL as well.
PPS: in general I wouldn't listen to hacker013 too much, he is too inexperienced to trust his advice in complex topics like this.
#167720 - hacker013 - Mon Mar 23, 2009 6:53 pm
josath wrote: |
PS: another think hacker013 forgot to mention, is that DLSI is GPL, meaning if you use it, you would be required to release all your code as GPL as well.
PPS: in general I wouldn't listen to hacker013 too much, he is too inexperienced to trust his advice in complex topics like this. |
I have added information about that on the download page -_-'' . And that second thingy, why do you think that?
_________________
Website / Blog
Let the nds be with you.
#167722 - elhobbs - Mon Mar 23, 2009 7:57 pm
dsli is most likely not the best solution for this problem - not to mention that the code that hacker013 sent you a link to has a serious flaw as I pointed out in the thread on the subject. in addition there is no native debugger support this type of code. while it is not impossible to debug it is quite difficult and time consuming.
#167723 - hacker013 - Mon Mar 23, 2009 8:46 pm
If many have problems with dynamic linking why has libnds then not a sort of dynamic linking support?
_________________
Website / Blog
Let the nds be with you.
#167724 - elhobbs - Mon Mar 23, 2009 9:06 pm
hacker013 wrote: |
If many have problems with dynamic linking why has libnds then not a sort of dynamic linking support? |
has anyone made a strong case for why libnds should have this functionality? I have not seen anything compelling.
#167725 - DiscoStew - Mon Mar 23, 2009 9:08 pm
Just because some people have problems with it doesn't mean it's a necessary feature that should be looked into.
To be serious, I highly doubt that even companies developing DS applications would use it.
_________________
DS - It's all about DiscoStew
#167734 - elwing - Tue Mar 24, 2009 10:27 am
the only use of dynamic linking would be for plugins... and/or mods for games... not really usefull seen the audience of DS homebrew... you're not writing the new half-life...
#167736 - hacker013 - Tue Mar 24, 2009 3:15 pm
elwing wrote: |
the only use of dynamic linking would be for plugins... and/or mods for games... not really usefull seen the audience of DS homebrew... you're not writing the new half-life... |
not yet ... :)
_________________
Website / Blog
Let the nds be with you.
#167738 - Emmanuel - Tue Mar 24, 2009 10:34 pm
elwing wrote: |
the only use of dynamic linking would be for plugins... and/or mods for games... not really usefull seen the audience of DS homebrew... you're not writing the new half-life... |
Umm... actually I was thinking on adding that sort of stuff :P
well... you are right... and, I don't feel like releasing source yet, so I won't use it...
#167744 - elwing - Wed Mar 25, 2009 9:37 am
Emmanuel wrote: |
elwing wrote: | the only use of dynamic linking would be for plugins... and/or mods for games... not really usefull seen the audience of DS homebrew... you're not writing the new half-life... |
Umm... actually I was thinking on adding that sort of stuff :P
well... you are right... and, I don't feel like releasing source yet, so I won't use it... |
hehe, don't follow strictly my gloomy talks, feel free to implement a plugin system in whatever app you are making :)
#167747 - hacker013 - Wed Mar 25, 2009 4:22 pm
And if you make a working one, maybe you can release that with a good license voor nds homebrewers.
_________________
Website / Blog
Let the nds be with you.
#167753 - albinofrenchy - Thu Mar 26, 2009 4:28 am
My two cents here: This is a radically different problem to solve than overlays. With most straight-up plugin architectures, you don't have to care about RAM usage so much. If we accept the 4mb limit, we simply could load a binary file of assembly, search it for entry points and save those memory addresses as functional pointers.
#167770 - Lazy1 - Thu Mar 26, 2009 7:09 pm
Why not compile scripts into bytecode and write a virtual machine to interpret the instructions?
This way you could write the scripts and interpreter on the PC for proper debugging before porting anything over.
#167771 - Dwedit - Thu Mar 26, 2009 8:19 pm
albinofrenchy wrote: |
My two cents here: This is a radically different problem to solve than overlays. With most straight-up plugin architectures, you don't have to care about RAM usage so much. If we accept the 4mb limit, we simply could load a binary file of assembly, search it for entry points and save those memory addresses as functional pointers. |
And also hope that the code is position independent.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#167779 - albinofrenchy - Fri Mar 27, 2009 5:27 am
Dwedit wrote: |
And also hope that the code is position independent. |
You mean, like in respect to having far vs short jumps? Can't think of any other issues. I don't think this would crop up really though; you'd compile the two things separately and setup everything as function pointers. Am I missing something?
#167784 - elhobbs - Fri Mar 27, 2009 12:39 pm
yes, I believe you need to something about the base address.