| View previous topic :: View next topic |
| Author |
Message |
daniel.franzini
Joined: 01 Sep 2009 Posts: 6 Location: São Paulo/SP (Brasil)
|
Posted: Tue Sep 01, 2009 8:36 pm Post subject: 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! |
|
| Back to top |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Tue Sep 01, 2009 9:23 pm Post subject: |
|
|
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: | int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
} |
|
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Thu Sep 03, 2009 2:12 am Post subject: |
|
|
You have to define exported function. Check the SDK example about PRXs. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Sep 03, 2009 8:05 am Post subject: |
|
|
| m0skit0 wrote: | | You have to define exported function. Check the SDK example about PRXs. |
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.
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. |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Thu Sep 03, 2009 12:00 pm Post subject: |
|
|
| For exporting variables, use pointers for user->user or kernel->kernel exports. You'll have to use an accessor function for kernel->user variable exports. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Sep 03, 2009 3:25 pm Post subject: |
|
|
| Torch wrote: | | For exporting variables, use pointers for user->user or kernel->kernel exports. You'll have to use an accessor function for kernel->user variable exports. |
Yeah, that's right. I was thinking of kernel prxs as that's what I've worked on. :) |
|
| Back to top |
|
 |
daniel.franzini
Joined: 01 Sep 2009 Posts: 6 Location: São Paulo/SP (Brasil)
|
Posted: Tue Sep 08, 2009 12:20 am Post subject: |
|
|
| thank you for the answers. i will work on this. |
|
| Back to top |
|
 |
phobox
Joined: 24 Mar 2008 Posts: 140
|
Posted: Tue Sep 08, 2009 7:44 am Post subject: |
|
|
| Torch wrote: | | For exporting variables, use pointers for user->user or kernel->kernel exports. |
Can you please tell me how to import variables? what do you mean by saying "use pointers"?
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 |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue Sep 08, 2009 9:47 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Tue Sep 08, 2009 8:34 pm Post subject: |
|
|
Or you can just use an object-oriented-like method, like
| Code: | 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. |
|
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Sep 09, 2009 2:46 am Post subject: |
|
|
| m0skit0 wrote: | Or you can just use an object-oriented-like method, like
| Code: | int my_global;
int return_my_global()
{
return my_global;
} |
|
I mentioned that earlier in the thread. ;) |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Wed Sep 09, 2009 8:57 pm Post subject: |
|
|
True, my bad, sorry. But maybe with an code example he/she could understand the concept better. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
|