Jump to content
  • Advertisement
Sign in to follow this  
timfrombriz

Alphablend - VB6/ASM

This topic is 2565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

Im looking for some help putting together a DLL that can be used from Visual Basic 6. Ive googled and searched and cant find enough pieces of the puzzle to really get me on the right track.

Im not sure if I need just a ASM compiler or a C++ compiler with inline ASM support to do this. I also believe that VB handles dll's (CDECL vs STDCALL) differently, and that needs consideration. Im not sure of the best compiler to use (considering speed of compiled code).

Im wanting to write a few alphablend functions based on its callers needs, and would like to know what the fastest method's are. I've googled and I hear MMX registers are good, and that for a 50% blend only (via bitshifting) achieves even faster results but with a constant blend rate.

Passing the parameters to the dll concerns me, (push/pop vs speed), so I presume a way around this would be to pass a pointer to a structure with the paramters. I presume VB6's byref and safearray dont void this optimization.

Im looking for speed, but want to develop within VB6. So Im guessing a DLL built from ASM is the best I can get to that goal. Im a complete novice outside of VB6, so any help with some direction or templates for getting me going on this would be amazing.

Share this post


Link to post
Share on other sites
Advertisement
VB6 can call any native dll function that uses the stdcall convention. Otherwise, it doesn't care how the dll was compiled. Just be careful with the parameter data types.

If you need to call cdecl functions from within VB6, you need to wrap them to stdcall on the native side. The wrap could be implemented as a separate DLL, of course.

You can get pointers to variables in VB6, by using the VarPtr (and other *Ptr) functions. The trick is that VB6 itself does not provide meaningful operations for dereferencing so obtained pointers. But if you import CopyMemory (or some other function for memory manipulation) from Win32 kernel, you can use the pointers for copying stuff around.

Byref causes VB6 to use an internal pointer for parameters that are decorated with it; I don't remember if it represents a standard long pointer or not. To be safe, I recommend using VarPtr and passing the pointers as byval Long (on VB side) if you do native interop. Note that VB6 does not do 64-bit at all.

Safe arrays is just a convention of passing array data and array bounds in the same context; it is just memory like any other variable.

Also, have you tried VB.net (or other .net languages)? The tooling is far superior to VB6 nowadays. You can get the express versions of the .net tools for free from MSDN; despite the price, they are very good especially for a hobbyist or solo developer.

Share this post


Link to post
Share on other sites

I've used this before: http://stereopsis.com/doubleblend.html and have another SSE version for images where I can take advantage of operating on multiple pixels at the same time.


Also why are you using VB6? It's dead.


VB6 is dead, but I have a thorough knowledge of it. I find it hard to migrate to a C++ IDE because theres so many questions I have. Debugging, why you need .h files in addition to .cpp files, how visibility exists between c++ files, how to get a small exe because a simple hello world churns out a massive executable.

I lack the time I guess to migrate, and I consider myself one of those hard core VB coders that utilise a lot of low-level programming concepts, like unions, pointers, inline functions in my vb code by different hacks. Although long term its locking me in, I look at it as if Im prototyping for the future lol.

As for VB.NET, I hate bloatware, and after being raped by Microsoft with VB6 (aka. killed it off) , I would never choose anything but a widely used, potentially open source environment that offers portability if I was to transition. So for the moment, VB6 it is, and maybe with some ASM skills along the way, I'll migrate easier down the track.

Share this post


Link to post
Share on other sites

VB6 can call any native dll function that uses the stdcall convention. Otherwise, it doesn't care how the dll was compiled. Just be careful with the parameter data types.

If you need to call cdecl functions from within VB6, you need to wrap them to stdcall on the native side. The wrap could be implemented as a separate DLL, of course.

You can get pointers to variables in VB6, by using the VarPtr (and other *Ptr) functions. The trick is that VB6 itself does not provide meaningful operations for dereferencing so obtained pointers. But if you import CopyMemory (or some other function for memory manipulation) from Win32 kernel, you can use the pointers for copying stuff around.

Byref causes VB6 to use an internal pointer for parameters that are decorated with it; I don't remember if it represents a standard long pointer or not. To be safe, I recommend using VarPtr and passing the pointers as byval Long (on VB side) if you do native interop. Note that VB6 does not do 64-bit at all.

Safe arrays is just a convention of passing array data and array bounds in the same context; it is just memory like any other variable.

Also, have you tried VB.net (or other .net languages)? The tooling is far superior to VB6 nowadays. You can get the express versions of the .net tools for free from MSDN; despite the price, they are very good especially for a hobbyist or solo developer.


Thank you for the information. Ive got so much information to get my head around and will ask when its a bit more clearer. Thanks for your time in replying.


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!