forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

dynamic libraries

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
daniel.franzini



Joined: 01 Sep 2009
Posts: 6
Location: São Paulo/SP (Brasil)

PostPosted: Tue Sep 01, 2009 8:36 pm    Post subject: dynamic libraries Reply with quote

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
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Tue Sep 01, 2009 9:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Thu Sep 03, 2009 2:12 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Sep 03, 2009 8:05 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Sep 03, 2009 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Sep 03, 2009 3:25 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
daniel.franzini



Joined: 01 Sep 2009
Posts: 6
Location: São Paulo/SP (Brasil)

PostPosted: Tue Sep 08, 2009 12:20 am    Post subject: Reply with quote

thank you for the answers. i will work on this.
Back to top
View user's profile Send private message
phobox



Joined: 24 Mar 2008
Posts: 140

PostPosted: Tue Sep 08, 2009 7:44 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Sep 08, 2009 9:47 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Tue Sep 08, 2009 8:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Sep 09, 2009 2:46 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Wed Sep 09, 2009 8:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group