Hi,
I will try to answer correctly your question but, I will probably not give all details here because it may be too long to explain.
1. What would de my code in PureBASIC .pb file ?
What user have to know is that your PB source code will have to follow the sample one that makes all includes for you.
Here is the default sample source code for upcoming 1.1 upgrade:
;
; ***********************************
; * *
; * PurePLUGIN TPC Plug-In Ver 2.00 *
; * *
; ***********************************
; ADDITIONAL NOTES: if you use the PureBASIC TPC tutorial that was released on the Thegamecreators newsletter:
; http://www.thegamecreators.com/data/newsletter/newsletter_issue_22.html#17
; Consider that the informations available here are more recent and must be used instead of old ones in the tutorial.
; Especially to String input/output.
; Ver 1.1 Addons: PurePLUGINVersion checking.
Structure PurePLUGINStructure
Version.l : Revision.l
EndStructure
Global PurePLUGIN.PurePLUGINStructure
; Define your UserNAME and UserCODE here. They were provided with the PurePLUGIN registration.
; If you set them incorrectly, your plugin may not work.
; We advice you to try to crypt your UserNAME and UserCODE in your DLL and uncrypt them only in memory
; for security reasons. If you simply put them here without crypting them, they can be seen by someone editing the DLL with an HEX editor.
Global UserNAME.s = "Put your username here"
Global UserCODE.s = "put your number code here"
; First of all, we include the constants that can be used to know which DarkBASIC Professional DLL's
; Were included by the compiler in the .EXE
IncludeFile "..\DBPro_Constants.pb"
; Now we include some commands I've done and that can sometimes be useful.
IncludeFile "..\AdvancedFunctions.pb" ; Pour contenir des fonctions spécifiques au système PurePLUGIN.
; we firstly included all structures needed to use DarkBASIC Professional's DLL set.
IncludeFile "..\DBPro_Structures.pb"
IncludeFile "..\DBPro_Structures_Init.pb" ; Setup for main, Init for sub.
; Now we inlude DarkBASIC Professional command set.
IncludeFile "..\DBPro_Init.pb" ; Pour l'initialisation secondaire pour les DLLs du pack.
; We now include the command that can be used directly from your TPC DLL.
; You can put in comments the DLL that are not used in your TPC Plugin to make your TPC Plugin be smaller.
IncludeFile "..\DBPro_Commands\DBProAnimationDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProBasic2DDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProBasic3DDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProBitmapDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBproCameraDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProCore.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProCSGDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProFileDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProFTPDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProImageDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProInputDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProLightDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProLODTerrainDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProMatrixDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProMemblocksDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProMultiPlayerDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProMusicDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProParticlesDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProSetupDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProSoundDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProSpritesDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProSystemDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProTextDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProVectorsDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProWorld3DDebug.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\AdvancedTerrain.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProGameFX.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\EnhancementsOV.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-USER_Commands\DBProMultiplayerPlusDebug.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-USER_Commands\DBProODEDebug.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-USER_Commands\ShaderData.dll_Commands.pb"
; PurePLUGIN Ver 1.1 Upgrades support :
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DarkPHYSICS.dll_Commands.pb"
; Ver 1.1 Addons: eXtends 1.3 version needed.
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProBasic2DExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProBasic3DExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProBitmapExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProCameraExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProEffects3DExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProFileExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProImageExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProLight3DExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProMatrixExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProMemblocksExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProMesh3DExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProMusicExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProParticles3DExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProRTSkyboxExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProSoundExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProSpriteExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProTextExtends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProVector2Extends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProVector3Extends.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-LICENSED_Commands\DBProVector4Extends.dll_Commands.pb"
; Ver 1.1 Addons: DKSHop plugin:
IncludeFile "..\DBProPLUGIN-USER_Commands\DKSHOP.dll_Commands.pb"
IncludeFile "..\DBProPLUGIN-USER_Commands\DKAVM.dll_Commands.pb"
;
Global PPInitialized.l ; Global variable to store 1 if darkBASIC Professional was successfully
; Initialized
; *************************************************************************************** Start()
; The main initialisation. Is called internally by DarkBASIC Professional when initializing the .EXE
; Do not forget to follow instructions on how to rename AConstructor00YAXXZ to ?Constructor@@YAXXZ
; Otherwise DarkBASIC Professional will not be able to initialize your plugin and you'll get a crash.
ProcedureCDLL AConstructor00YAXXZ()
If *GlobPtr = 0 : InitialiseCorePtr() : EndIf
If PPInitialized = 0
PPInitialized = InitDLLBase()
EndIf
GetPPVersion()
EndProcedure
; *************************************************************************************** Quit()
; You can do the same thing than with Contructor if you need to remove stuffs from memory when the program
; exit. You'll have to rename the ADestructor00YAXXZ to ?Destructor@@YAXXZ with a tool like XVI.
; Follow instructions on how to rename constructor procedure to make changes with destructor too.
ProcedureCDLL ADestructor00YAXXZ()
EndProcedure
; **************************************************************
; This function ensure your plugin is inialized
ProcedureCDLL.l PPInit()
If *GlobPtr = 0 : InitialiseCorePtr() : EndIf
If PPInitialized = 0
PPInitialized = InitDLLBase()
EndIf
ProcedureReturn PPInitialized
GetPPVersion()
EndProcedure
; **************************************************************
; Now you can include the PureBASIC source code file that will contain all your TPC Procedures
IncludeFile "PurePLUGIN-YourProcedures.pb"
;
; **************************************************************
; Simple informations about your plugin.
DataSection
DONNEES:
Data.s "DarkBasic Professional PurePLUGIN DLL Sample / "
Data.s "PurePLUGIN-SampleDLL.dll Ver 1.1 [ 070205 ] / "
Data.s "Frédéric Cordier - Odyssey-Creators(c)2005-2007 "
EndDataSection
As you can see, there are many sections in that file and also many includes.
I will describe them :
[PluginVERSION Checker]
Structure PurePLUGINStructure
Version.l : Revision.l
EndStructure
Global PurePLUGIN.PurePLUGINStructure
These few lines define 2 values : PurePLUGIN\Version and PurePLUGIN\Revision. Their values will then be the reflect of the installed
Compiler\PLugINS-User\PurePLUGIN.dll version
You can read them from within your PureBASIC source as standard integer value to know which version will be used. It's useful if someone overwrite the PurePLUGIN.dll version with an older version that does not handle additional plugins you need for your plugin to work.
[User Identification]
Global UserNAME.s = "Put your username here"
Global UserCODE.s = "put your number code here"
To make PurePLUGIN.dll send you the needed informations to use DarkBASIC Professional DLLs and additional plugins, you'll have to put your UserNAME and UserCODE here (we advice you to crypt them and decrypt them in memory to prevent someone from ripping your IDs)
Please, becarefull with PurePLUGIN.dll, if you're not sure it's an original one. I will put a link for the latest PurePLUGIN.dll file at www.odyssey-creators.com so, you can be sure that the version on the site is the original one.
[DLL constants
IncludeFile "..\DBPro_Constants.pb"
This file add extra informations to know if a DarkBASIC Professional DLL or Additional plugin was included in the final DarkBASIC Professional application that use your plugin.
How it work ?
It simply add informations this way :
;
; Here is the list of all DLL slots. Each slot will return 1 if DLL was included in the
; DarkBASIC Professional compiled .exe
;
#DBProAnimation = 1
#DBproBasic2D = 2
#DBProBasic3D = 3
#DBProBitmap = 4
#DBProCamera = 5
#DBProCore = 6
#DBProCSG = 7
#DBProFile = 8
#DBProFTP = 9
#DBProImage = 10
#DBProInput = 11
#DBProLight = 12
#DBProLODTerrain = 13
#DBProMatrix = 14
#DBProMemblocks = 15
#DBProMultiPlayer = 16
#DBProMusic = 17
#DBProParticles = 18
#DBProSetup = 19
#DBProSound = 20
#DBProSprites = 21
#DBProSystem = 22
#DBProText = 23
#DBProVectors = 24
#DBProWorld3D = 25
;
#DBAdvancedTerrain = 32
#DBGameFX = 33
#DBEnhancementsOV = 34
;
#DBMultiPlayerPlus = 48
#DBODE = 49
#DBShaderData = 50
#DKSHOP = 51
#DKAVM = 52
;
; Ver 1.1 Upgrades support :
#DBDarkPHYSICS = 35
#Basic2DExtends = 64
#Basic3DExtends = 65
#BitmapExtends = 66
#CameraExtends = 67
#Effects3DExtends = 68
#InitExtends = 69
#FileExtends = 70
#ImageExtends = 71
#Light3DExtends = 72
#MatrixExtends = 73
#MemblocksExtends = 74
#Mesh3DExtends = 75
#MusicExtends = 76
#Particles3DExtends = 77
#RTSkyboxExtends = 78
#SoundExtends = 79
#SpriteExtends = 80
#TextExtends = 81
#Vector2Extends = 82
#Vector3Extends = 83
#Vector4Extends = 84
;
With that, you can call PurePLUGIN.dll to know if a DLL was loaded. for example, for the DarkBASIC Professional DBproBasic2D Debug DLL, do this in your PC Source code :
Result.l = GetDLLInitialized( #DBProBasic2D )
If Result = 1, then the DLL is loaded and can be used from your plugin.
[DLL Structures]
IncludeFile "..\DBPro_Structures.pb"
IncludeFile "..\DBPro_Structures_Init.pb" ; Setup for main, Init for sub.
These two includes setup all needed structures to use DarkBASIC Professional DLL and additionals plugin from your own one.
Sample from DBPro_Structures.pb :
; GlobStruct for internal calls.
IncludeFile "..\DBPro_Structures\DBProGlobStruct6.4_Structures.pb"
;
; DarkBASIC Professional Compiler\PlugIN content.
IncludeFile "..\DBPro_Structures\DBProAnimationDebug.dll_Structures.pb"
IncludeFile "..\DBPro_Structures\DBProBasic2DDebug.dll_Structures.pb"
IncludeFile "..\DBPro_Structures\DBProBasic3DDebug.dll_Structures.pb"
IncludeFile "..\DBPro_Structures\DBProBitmapDebug.dll_Structures.pb"
IncludeFile "..\DBPro_Structures\DBproCameraDebug.dll_Structures.pb"
....
...
[The DarkBASIC Professional and additionals plugins commands sets]
The next includes files add the needed Procedure to call directly DarkBASIC Professional and Additional plugins commands from your own plugin:
IncludeFile "..\DBPro_Commands\DBProAnimationDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProBasic2DDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProBasic3DDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBProBitmapDebug.dll_Commands.pb"
IncludeFile "..\DBPro_Commands\DBproCameraDebug.dll_Commands.pb"
...
...
[Plugin Activation]
If your plugin is correctly initializd with PurePLUGIN.Dll, you'll receive the informations and the value:
Global PPInitialized.l ; Global variable to store 1 if darkBASIC Professional was successfully
will be set to one.
You can check this from everywhere in your plugin to know if it is activated or not. If not, you can't use DarkBASIC Professional and Additional plugins commands from your own plugin and a popup message will appear on DarkBASIC Professional application that'll use your plugin saying it is not activated.
[The Constructor procedure]
DarkBASIC Professional can make some initialisations from the Constructor command. the main problem is that PureBASIC can't compile DLL with functions using decorated form. You'll then have to make changes from yourself after compilation:
ProcedureCDLL AConstructor00YAXXZ()
If *GlobPtr = 0 : InitialiseCorePtr() : EndIf
If PPInitialized = 0
PPInitialized = InitDLLBase()
EndIf
GetPPVersion()
EndProcedure
This procedure makes all initialisation of the plugin.
Once your DLL is compiled, you'll have to modify the procedure name with an HEX editor (it will be explained later)
The PPInit() procedure do the same job but is here for security reasons.
ProcedureCDLL.l PPInit()
If *GlobPtr = 0 : InitialiseCorePtr() : EndIf
If PPInitialized = 0
PPInitialized = InitDLLBase()
EndIf
ProcedureReturn PPInitialized
GetPPVersion()
EndProcedure
[Your DLL commands]
IncludeFile "PurePLUGIN-YourProcedures.pb"
This include will add a file where you can put all your ProcedureCDLL that will make the final DarkBASIC Professional commands you've created.
Here are all the informations about the main DLL .pb file.
All your procedure will follow the same scheme that I explained months ago in the old PureBASIC tutorial on TheGamecreators Newsletter :
http://www.thegamecreators.com/data/newsletter/newsletter_issue_22.html#17 but updated to new DarkBASIC Professional internal specifications and with a more stable and professional way of working (and also faster :p)
Once you've compiled your DLL, you'll have to use a tool like RESOUCE HACKER to add String Table. This part of a DLL development is explained in the Tutorial on the newsletter and in the PurePLUGIN Help. I'll just comment here that String table are the direct link between your DLL procedures and DarkBASIC Professional commands you've created.
The last part of the development will be to replace (with an HEX editor like freeware XVI32) the AConstructor00YAXXZ command with ?Constructor@@YAXXZ
It's an easy task that will take less than 1 minutes to achieve :p And is needed because DarkBASIC Professional doesn't know non decorated Constructor function.
I hope these explanations answered your questions 1, 2 and 3.
Technically, you can add as many new commands as you want. for example, my XQuadEditor.DLL developed in PureBASIC add more than 300 new commands handling all the X-Quad Editor game engine structures and functionalities. PureBASIC Can do more, and PurePLUGIN Handle this too
The only differencies will be that, more commands you'll have in, bigger the DLL will be. (and more String Table you'll have to do to create the new commands)
I Hope I've answered all your questions.
Regards,
Fred