dynamic libraries
-
- Posts: 5
- Joined: Tue Sep 01, 2009 8:24 pm
- Location: São Paulo/SP (Brasil)
dynamic libraries
Hi all
I'm porting the BennuGD for the PSP. BennuGD is a programming language for writing 2D games.
In doing this, there is the need of some sort of dynamic loading (on Windows it is implemented using DLLs and in Linux, using Shared Libraries). Question: is a PRX module good for this? If a PRX is just in the same folder as the binaries, is the PSP able to load it?
I think i can "emulate" the behavior of i.e DLLs using loading/unloading functions of PRXs.
Does anyone has some other ideas on this?
Thank you!
I'm porting the BennuGD for the PSP. BennuGD is a programming language for writing 2D games.
In doing this, there is the need of some sort of dynamic loading (on Windows it is implemented using DLLs and in Linux, using Shared Libraries). Question: is a PRX module good for this? If a PRX is just in the same folder as the binaries, is the PSP able to load it?
I think i can "emulate" the behavior of i.e DLLs using loading/unloading functions of PRXs.
Does anyone has some other ideas on this?
Thank you!
You can use a prx as a DLL in windows. A prx can contain some functions. I think it's simpler to create just a librarie which you link against.
Code: Select all
int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
Also remember that while functions can be exported, the SDK doesn't allow you to access exported variables. If you wish to use variables from the main app, you have to pass them (or a pointer) in to the function, and if you wish to access a variable in the prx, you need to make accessor functions in the prx.m0skit0 wrote:You have to define exported function. Check the SDK example about PRXs.
For example, if the prx has a variable called myVariable, to get or set it, you need to export functions like GetMyVariable() and SetMyVariable() - the main app cannot directly manipulate myVariable. In that respect, prx's are different from dlls and linux shared libraries.
-
- Posts: 5
- Joined: Tue Sep 01, 2009 8:24 pm
- Location: São Paulo/SP (Brasil)
Can you please tell me how to import variables? what do you mean by saying "use pointers"?Torch wrote:For exporting variables, use pointers for user->user or kernel->kernel exports.
do you mean to use a pointer and set to this pointer the address of the exported variable from the other module? but how to get this address?
thanks
Ciao! from Italy
Call a function that returns a structure full of pointers to the variables you wish to access. Something like
struct myPointers {
int * var1;
int * var2;
char * var3;
};
When the prx function returns a pointer to the struct, you then have pointers to all the stuff in the PRX you want. You'd do something similar for passing pointers into the prx as well. This only works for a user prx <> user app or kernel prx <> kernel app.
struct myPointers {
int * var1;
int * var2;
char * var3;
};
When the prx function returns a pointer to the struct, you then have pointers to all the stuff in the PRX you want. You'd do something similar for passing pointers into the prx as well. This only works for a user prx <> user app or kernel prx <> kernel app.
Or you can just use an object-oriented-like method, like
Code: Select all
int my_global;
int return_my_global()
{
return my_global;
}
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
I mentioned that earlier in the thread. ;)m0skit0 wrote:Or you can just use an object-oriented-like method, like
Code: Select all
int my_global; int return_my_global() { return my_global; }