|
Post by DJLinux on Apr 16, 2007 11:29:30 GMT -5
First sorry about my bad english I wrote a short test DLL (in assembler) and exported Basic4GL_Query as CDECL (without @12) Basic4GL_Init as CDECL (without @0) I can select my test plugin Qwery and Init will be called from Basic4gL.exe. Now my question the Plugin interface it self is it simple a list with pointers on c function? static IDLL_Basic4GL_Plugin Plugin struct IDLL_Basic4GL_Plugin Plugin .Load = @MyPlugLoad .Unload = @MyPLugUnload .Start = @MyPlugStart .End = @MyPlugEnd .Pause = @MyPlugPause .Resume = @MyPlugResume .DelayedResume = My@PlugDelaydResume .GetError = @MyPlugGetError .ProcessMessages = @MyPlugProcessMessages end struct or will it be called as mebers in a CLASS? @myplugload is for example a pointer on a CDECL function in assembler. From my point of view the diffrent (as assembler coder) is the name mangling. GCC and VS produce difrent names. For short is it called from Basic4GL as "C++" CLASS or as list of pointers on "C" functions? thanx for your infos. Joshy
|
|
|
Post by DJLinux on Apr 16, 2007 15:21:17 GMT -5
After more tests i got it.
Nice now i can add ODE as an PLugin and my own DSP Soundlib.
Joshy
|
|
|
Post by DJLinux on Apr 16, 2007 20:47:36 GMT -5
f*** now Basic4GL.exe calls Basic4GL_Query and Basic4GL_Init Load, Unload, End, Pause, Resume, DelayedResume, ProcessMessages
and if i return false for example in Load
Basic4GL calls the Error function
Looks ok so far and this was why i wrote i got it in assembler
But if i try to access any Param for example: If i fill the param Error (array of chars) "with my own message" + " 0" Basic4Gl crashes if it will print the message in the MessageBox.
If i don't put my message in the array of chars Basic4Gl prints the right empty Error messagebox.
Same with the param "bool isStandaloneExe" in Load it is never true or false.
Now what can it be that all members of the plugin interface are called but i can't use any param.
I know that all my plugin members must using CDECL !
Thank you for any help/info
Joshy
|
|
|
Post by Tom Mulgrew on Apr 17, 2007 5:08:18 GMT -5
It seems to me that you're trying to write C++ methods in assembler. This is possible but you have to know a lot about C++ calling conventions.
If I were you, I would use C++ for the plugin skeleton. There's example code there which is compiled, tested and working. You can then call your assembly code from the C++ skeleton, either using inline assembly, or by assembling your routines as C callable and calling them from the C++ part of the plugin.
Just seems easier than trying to duplicate what a C++ compiler does in assembly code. Having said that, if you really *must* do everything in assembler, you might consider compiling the example plugin in C++ and then looking at the assembly that it outputs, and check it against your stack frame code to see if there's anything you might have missed.
Cheers, -Tom
|
|
|
Post by davy on Apr 17, 2007 18:49:50 GMT -5
Does the plugin interface use any strictly C++ features?
If not, writing a simple plugin wrapper in C would make assembly interfacing SOOO much easier.
C++'s name mangling is going to make it impossible... I wouldn't even bother with that if I were you. Write a wrapper for C, then interface C with assembly.
|
|
|
Post by Tom Mulgrew on Apr 18, 2007 5:36:59 GMT -5
Does the plugin interface use any strictly C++ features? The plugin interface works by passing C++ interfaces back and forth between the plugin and main application, so yes.. C++ is required. However you can quite easily call standard C functions from C++. You just need to declare them as: extern "C" { int someFunction(char some, int params); void someOtherFunction(); ... (etc) } This tells C++ that the function is an external C style function and should not be name mangled. So if the assembly code exposes functions as regular C functions then the C++ code can call them fine.
|
|
|
Post by DJLinux on Apr 18, 2007 14:13:08 GMT -5
thanx for this infos.
My mistake cames from the wrong doc "C / C++ interface" but it must be a "C DLL entry" and "C++ interface".
again thanx
Joshy
I wonder my that all interface members Load, Unload, Start, End and so on are called (without any crash) my C functions in assembler.
|
|
|
Post by DJLinux on Apr 26, 2007 9:49:28 GMT -5
"Damm" i got it work now ;D
The hidden member THIS is not only a pointer of its own class it is **class
in C++:int Plugin::Load(IDLL_Basic4GL_FunctionRegistry registry,bool IsStandaloneExe) in Assembler:int Plugin::Load(Plugin **_This, IDLL_Basic4GL_FunctionRegistry **registry,bool IsStandaloneExe)
simple after i know it.
By the way that mean's all BASIC languages for example PowerBASIC, FreeBASIC, ... with CDECL and pointer support can call any C++ interface.
From Basic4GL SDK example: In FreeBASIC:function PlugLoad CDECL ( _this as PLUGIN ptr ptr, registry as IDLL_Basic4GL_FunctionRegistry ptr ptr, blnIsExe as bool) as integer
registry[0]->RegisterFunction(registry,"Max", @Func_Max, DLL_BASIC4GL_FLOAT) registry[0]->AddParam(registry,DLL_BASIC4GL_FLOAT) registry[0]->AddParam(registry,DLL_BASIC4GL_FLOAT) return 1 end function
Joshy
|
|
|
Post by DJLinux on Apr 26, 2007 18:32:31 GMT -5
Need short infos again. 1.) Is there no VEC3 datatype in BvGL? [solved] 2.) Can you call any Plugin function with UDT's like this. TYPE test dim mass#, friction#, stiffnes# END TYPE dim a as TEST AnyThing(a) 3.) Is there no user defined SUBS and/or FUNCTIONS ? [solved] Last but not least 4.) How can a Plugin signal an event to a running BvGl programm? (for example if a 3d object collision happents in the plugin) Thank you very mutch for your help. Joshy
|
|
|
Post by DJLinux on Apr 29, 2007 21:55:01 GMT -5
In scope of my last post i need answer for question 2.) and 4.) ?
Tom@ thanx for your mail (N,M) arrays works now with the optional params. :-)
Next question the "simple" pointers from the VM are virtual or real addresses so a plugin can read/write to it?
1.) What are the real limitation of Basic4GL? I mean maximal use of memory for CODE, VARS, SOUND and TEXTURES in MB.
2.) How many Stackspace (1 or 4MB) shares B4GL with it's loaded Plugins?
3.) I know the Linux version of BvGL are an other project but support it shared Libs as Plugins too? (for my self i use ODE with Linux too) Thanx for infos.
Joshy
|
|
|
Post by Tom Mulgrew on Apr 30, 2007 3:01:35 GMT -5
2.) Can you call any Plugin function with UDT's like this. TYPE test dim mass#, friction#, stiffnes# END TYPE dim a as TEST AnyThing(a) You cannot pass structures to a plugin function with Basic4GL (as it stands). Unfortunately there's no concept of event in Basic4GL. I put in a limit of 400megabytes for variable data. However other resources, like sounds, images etc, you can basically allocate as much as your system can handle. You know, I'd never really looked before. Turns out it has a 1MB stack. I could build a version with a 4MB stack without too much difficulty though. Davy maintains the linux version of Basic4GL. I don't think it supports plugins at this time. There's a new project called "Basic4Games" in development that is based on the Basic4GL source code, which has a Windows version and Linux version and supports plugins on both. (You can download the source from sourceforge. sourceforge.net/projects/basic4gl). It is still in development though. -Tom
|
|
|
Post by davy on Apr 30, 2007 10:17:28 GMT -5
Well, the actual linBasic4GL was mostly supermonkeys work (well, Tom's, but supermonkey did all of the work porting it), and I was working on a Basic4SDL... But I don't think either of us have enough time to really get to work on them.
I also don't like C++ much these days (I spend my coding in C, assembly, python, or php&javascript) I would love to port it to C, but... Whew... That would take a LOT of time. I don't think it would be too hard, since it's not terribly object oriented, but there is a lot of use of the C++ STL.
Anyway, linux's shared object interface is pretty simple, it wouldn't be too hard to patch it in.
|
|
|
Post by Supermonkey on Apr 30, 2007 12:43:07 GMT -5
Yeh thats the way its been for me but I finish uni in a couple of weeks and I hope to spend alot more time on it then. It has to be said though davy did a good 50% of the work, I get very lazy and when I have completed one goal I often drop off a bit, but davy's update got the project up to the level it is now.
|
|
|
Post by DJLinux on Apr 30, 2007 23:54:18 GMT -5
Next question the "simple" pointers from the VM are virtual or real addresses so a plugin can read/write to it? Joshy
|
|
|
Post by Tom Mulgrew on May 1, 2007 3:09:35 GMT -5
They are virtual (copies). So you cannot change their values.
However I could add variable (read/write) parameters if necessary.
To be honest, you're the first person (that I know of) to use the plugin interface for a project of this size, so I don't mind doing some Basic4GL development if it will make the plugin better.
Cheers, -Tom
|
|