News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

ZX SOUND

Started by baggey, November 09, 2012, 11:59:48 AM

Previous topic - Next topic

monkeybot

check the dll bit in the docs.

kevin

#16
  The wrapper is 'PB' interface (some pB code) between PB and the outside world.   The simple option is via LinkDLL / EndLinkDLL.  

 So if you had a DLL called "CoolStuff.Dll"  and internally it's got a function called "DoTheCoolStuff" which expects a pair integers as parameters..  The interface to that function could be defined like so.

PlayBASIC Code: [Select]
linkDll "CoolStuff.Dll"

DoThisCoolThingInMyPbProgram(Param1,Param2) alais "DoTheCoolStuff"

EndlinkDll




   So DoThisCoolThingInMyPbProgram(Param1,Param2) is what PB is expecting you to use,  when you call this function, It calls the function inside the DLL called "DoTheCoolStuff".    The name can't be resolved, the call will error.  

  There's two obvious issues.  First how to know what parameters the dll functions use ?  Good question, there's no way of finding out without the information on the DLL and second,  often DLL functions names aren't straight text like this example, often they're decorated names (hashes of what seems like random characters but aren't).   There's any number of tools out there on the web to help with this.  But without some type of SDK for the library, it's a bit of lottery.




     
 


baggey

#17
Righ...t, so a .dll is already a program with possible useful functions within.

I have dev C++ 4.5 from bloodshed. I have snipeets of code which emulate AY or Beeper in Java and C++.
So a java platforn should be able to do .dll's as well.

Im assuming now that if i have source. i can turn into a .dll. With dev C++!?

At this stage then, i can call the function with the .dll loaded.

Ive hered of SDK loads of times but what is it?

In the Examples we have

PlayBASIC Code: [Select]
 LinkDll "user32.dll"                                            ; user32.dll  Which is part of windows? This must hold a lot of functions if you know what to call?
HideMouse(State) Alias "ShowCursor" ; Our Hidemouse on or off. I assume is passed to the actual function showcursor in the .dll
EndLinkDll

Do
Cls RGB(0,0,0)
Print "Press Mouse Buttons to hide/show mouse"

If MouseButton()=1 Then HideMouse Off
If MouseButton()=2 Then HideMouse On

Sync
Loop




i really appreciate all the help and advice  ;)

Kind regards Baggey
Jesus was only famous because of his dad

kevin

Quote
Righ...t, so a .dll is already a program with possible useful functions within.

  They're just a preformed chunk of executable program code.  UNlike a program though, the easiest way to imagine a DLL, is its just an external set of functions.   


Quote
I have dev C++ 4.5 from bloodshed. I have snipeets of code which emulate AY or Beeper in Java and C++.
So a java platforn should be able to do .dll's as well.

Im assuming now that if i have source. i can turn into a .dll. With dev C++!?

At this stage then, i can call the function with the .dll loaded.


  You could write / build it from existing code, or you search for some pre-existing Sound/Music DLL's that do what you want already.   They are out there. 



QuoteIve hered of SDK loads of times but what is it?

    It's the doc's for how to use the thing in question..  Normally you get something that outlines of what functions do, parameters and any constants etc the library uses.   Depending upon the intended audience of the DLL, depends on how low level the docs and functions are.   Making some easier to work with than others.