Important alert: (current site time 7/16/2013 3:27:22 AM EDT)
 

winzip icon

ASM+VB = VB Hardcore. REALTIME Picture Fade In/Out

Email
Submitted on: 10/1/2000 11:28:26 PM
By: Dmitry Apukhtin  
Level: Advanced
User Rating: By 50 Users
Compatibility: VB 6.0
Views: 47717
 
     Well, guys, are you ready for real speed? Real-time TRUECOLOR software-only picture pixel-by-pixel processing (no hardware accelerator stuff) in BACKGROUND, 50+ FPS of truecolor 640x480 image fade in/out with transparent full-area text scrolling - all in VB source, no DLL/OCX's - is it possible? Of course NOT :) Until you inject some assembler (machine codes) into it;-) Yes, hell working machine codes drive this sample, as well as some tricks abount DIB-images processing. Although nothing special in app itself (just slide show fading pics in and out) and you could get more fascinating stuff from DirectX, BUT! It's all in VB and works in IDE almost as fast as in compiled EXE. So, take a look at this stuff. And I hope you won't vote it "poor" just because "I don't f@%$ understand how the hell it could be!" :-) The code is real VB hardcore. So, gimme ur "wow!" ;-) BTW, that FPS was on my PII-400/RIVA TNT2. I wonder what's yours? Let me know!

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :ASM+VB = VB Hardcore. REALTIME Picture Fade In/Out
'**************************************
a "couple"
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
10/2/2000 12:57:06 AMWarren

I didn't look at the code, but just ran the exe. Fading runs very smooth. I got about 60 fps, but I have a old voodoo 3 card. Well done!
(If this comment was disrespectful, please report it.)

 
10/2/2000 2:14:53 AMAsmodeus

It took me a while, but I think I finally see what this is doing.. far out stuff.. am i reading this right.. are you converting the .asm into its native hex code?
(If this comment was disrespectful, please report it.)

 
10/2/2000 5:22:20 AMUlli

It would be nice to have the ASM code included in the source. Otherwise a great idea. How do you pass Paramters to the ASM stuff ?
(If this comment was disrespectful, please report it.)

 
10/2/2000 1:26:13 PMSimon Price

I don't understand assembler, and I don't understand how you use VB and assembler together either. But I do understand that 50 FPS alpha blending is cool. Well done man.
(If this comment was disrespectful, please report it.)

 
10/2/2000 8:11:55 PMBRL

hey, Dmitry Apukhtin ... where do you live?
(If this comment was disrespectful, please report it.)

 
10/3/2000 12:23:44 AMJustin Boxwell

sir, you truly are the king of kings
(If this comment was disrespectful, please report it.)

 
10/3/2000 2:20:21 AMRichard Petithory

This is very interesting and could be extremely usefull, but even for fairly experienced VB programmers, it is extremely cryptic. I give it an excellent rating because that is what it is, but I frown upon your commenting. It seems to me that a post like this to a site like this is more showing off than it is a helpfull tutorial... I am bitching because I would love to know how this works, but I'm afraid that even with a good ammount of time put in, I will still not understand it. I'm sure others feel the same way. Anyway, extremely good job - I would like to learn from it.
if you have any sort of further information on the web on how to start out something like this, or could possibly forward us (PSC users) to more information, please do so. Thanks!
(If this comment was disrespectful, please report it.)

 
10/3/2000 4:01:42 AMRichard Petithory

I'm not sure if the author is going to read this or not... I've been looking over the code for a while now (its 4 in the morning) and I understand the logic behind it... copying the instructions you formed into memory, but what I do not understand is where the strings you use in the 'XFade' sub, the 'RMChar' sub, etc. come from.
(If this comment was disrespectful, please report it.)

 
10/3/2000 5:23:01 AMmichael

Hello Dmitry,
I mean this is a good job.
I give you a Excellent rating for this job but I´m not understand the code.
Make new Examples and we can learn from you :-)
>
Regards Michael
(If this comment was disrespectful, please report it.)

 
10/3/2000 12:17:56 PMKamilche

Ow, your code hurt my head. :-P

The code ran at 10 fps on my 233 mhz Pentium II running Windows 95, 256 megs ram.

I have concerns about how portable to different machines it is, considering it's done in assembler. In addition, the speed is quite good enough to use for games (at least for older machines.)

In short, it's great that you managed to do assembler in VB, but ... why bother? :-P I can get > 100 fps on this machine, using DirectX and DirectDraw (but not doing alpha fades.) Show me a fast replacement for GDI transparent blitting, that doesn't use DirectX, and I'll sit up and take a closer look.
(If this comment was disrespectful, please report it.)

 
10/3/2000 1:43:13 PMrokinroj

I gave you a vote of excellent because yours is one of the first, if not the first post of its kind. And as always we should award original ideas and not the same tired mp3 players or message box makers that get submitted every day. The code is clearly out of my league, but it ran flawlessly at 50 fps, and looks great!
(If this comment was disrespectful, please report it.)

 
10/4/2000 12:40:50 PMDmitry Apukhtin

hey guys thanx for comments.
in fact, I was going to describe technique of this "technology" (incapsulating machine codes in VB) step by steb, including debugging VB stuff in VC IDE, but wanted to see first if it worth to, if there are enough understanding and eager people. I won't say so far... sad truth is that people that are able to "communicate" with PC on this level are usually C-guys, not VB... or maybe it was wrong place to post to...

(If this comment was disrespectful, please report it.)

 
10/4/2000 12:41:42 PMDmitry Apukhtin

anyway, Warren,Simon,Justin (especially :), michael,rokinroj - thanx guys!

BRL - why? 8-) wanna tell me in face what do you think about me? hehe :)

Richard - my respects. you are that kind of programmers I was counting on posting this stuff. hope you enjoyed breaking apart this sample :) "these string" came from native assembler code-bytes. in short: I write and debug asm procedure in VC environment and then do convert resulting bytes (machine codes) into their hex representations - each pair of chars in these strings are one code byte actually. keep going! RTFM! MSDN is the only and best source on knowledge in MS-world.


(If this comment was disrespectful, please report it.)

 
10/4/2000 12:42:29 PMDmitry Apukhtin

Ulli - thanx man for first real question. that's not problem, in fact, I do not _pass_ parameters :) it's VB compiler's business to generate calling code which PUSH'es stuff in stack, I just pull DWORD's from stack and use them in asm code. for example, first param are in stack by [ESP+4], second - [ESP+8] etc so I do "mov EAX,[ESP+4]" etc. as for ASM source - man, what for? besides that it is as simple as lodsb/mul/stos in loop (for xFade proc), the point of this post wasn't to show cool asm tricks.


(If this comment was disrespectful, please report it.)

 
10/4/2000 12:43:56 PMDmitry Apukhtin

Kamilche - oh, boy. why bother??? sorry (nothing personal_ - but why bother writing lame comments, tell me. he could make 100 fps not doing a/blending. huh. u know what, I could do 1000fps bouncing one pixel around. so what? u couldn't even notice that since most VGA cards runs max 120Hz of V/refresh rate. go buy your next 3D accel and tell everyone how'd _you_ make your 100 fps. oh, men. you didn't even realize that this post wasn't about pictures nor animations.

ok, too much typing for today :)
sorry for my poor english, if any.
thanx everybody
(If this comment was disrespectful, please report it.)

 
10/4/2000 12:50:48 PMMichael Isaac

This is a good example. If possible I would like you to create a more detailed example on how to copy asm code to the memory, hows it works and how it relates to vb. Good code.

(If this comment was disrespectful, please report it.)

 
10/4/2000 8:45:27 PMDigital Paradigm

Very cool and very fast!
(If this comment was disrespectful, please report it.)

 
10/6/2000 3:29:30 AMRings

Interresting Project.I've also coded
in ASM since DOS-Times.How do you extract the Hex-values out of the ASM-Code ? MOVEB AL,BL = ????
JMP ADRESS = ????

(If this comment was disrespectful, please report it.)

 
10/6/2000 3:07:29 PMNathan Evans

This is quite good..
only i got ~20fps on my computer..

I have an athlon 700, gforce 256..

It may be because i was running win2k at the time of the test, and since the gfx support isnt very good..

I'll try it on win98 and see how it goes..

It appeared to flicker at a very very fast rate as well..
(If this comment was disrespectful, please report it.)

 
10/6/2000 5:03:52 PMDmitry Apukhtin

Nathan, switch your display colors to more than 256

(If this comment was disrespectful, please report it.)

 
10/12/2000 4:18:52 AMNLS - Nonlinear Solutions

Let me note some things ...

* This stuff is not all that mysterious, the techniques used have been around for some years (compare the work of David Brebner or my alphablitter at www.inode.at/nls)

* There is a great source on ASM+VB, the site of Patrice Scribe at www.chez.com/scribe

* As long as the assembler code hasnt been optimized to use MMX instructions like quadmoves or PIII specifics, it should run on any Pentium (eg, my latest ASM alpha engine uses MMX and therefore only runs on PII or above)

* Anyway, great work, you've got my vote, though I would appreciate a look at your ASM code (difficult to evaluate just how good youve done w/o it)


(If this comment was disrespectful, please report it.)

 
10/16/2000 7:42:12 AMFredrik Qvarfort

For everyone that wants the ASM code (which is missing here) you can download the NASM disassembler from

ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/nasm097s.zip

then you can run the ndisasmw -u asmcode.asm > asmcode.txt

where asmcode.asm is a textfile with the machine code (this is the hexadecimal values, converted to binary data, in the asm class file).
(If this comment was disrespectful, please report it.)

 
10/17/2000 7:08:46 PMJean-Philippe Leconte

I've been doing enough assembler to understand what ur doing... copying binary asm to memory and replacing methods adresses by the adresses of your asm... really neat :) people should add more code like this... I had already tried replacing proc bodies, but had a lot of problems... your solution is fast enough for me... now I bang my head on the wall not having thought of it before ;P
(If this comment was disrespectful, please report it.)

 
11/30/2000 9:56:45 AMKRAPHICS

You did goooooooood man.
Your code knocked me off my feet.
I found the code surfing for image processing code for VB. Your code will forever be a friend of mine.

Do some more.........
(If this comment was disrespectful, please report it.)

 
12/1/2000 7:45:27 AMLinguar

After looking at this procedure, and with my limited knowledge of API, I see what you're doing...
It's nice work.

Couldn't someone use something similar to this In Visual Basic to script parts of games and convert them to Machine code and directly run them (after being converted to the correct hexadecimal base, of course)?
(If this comment was disrespectful, please report it.)

 
12/1/2000 11:13:32 AMCovertLoop

Sorry, bro, but the fading sucked. Too much flicker going on. Look at it from a Users point of view. The Users don't give a rat's a§§ about what you did with your coding and/or converting. They're going to look at it and say to themselves ''What's the deal with the flickering?''. Fix the flicker, and you've got it.
(If this comment was disrespectful, please report it.)

 
12/1/2000 1:44:30 PMJon Furner

I understand how it works, but I have one question: How can I learn Assembly? I have been programming VB for 5 years, and I learned C. I think that this is just what VB needs, but I don't know how to do it. Not very many resources are just lying around any more. It makes it hard for those of us that are curious.
(If this comment was disrespectful, please report it.)

 
12/1/2000 3:53:47 PMMichael L. Barker

wow just because you asked ;) Nice job.
(If this comment was disrespectful, please report it.)

 
12/1/2000 5:14:07 PMBrian G.

Get a book on assembler for $50 it is hard reading but you will learn allot. I have a feeling this code uses a windows API call called by machiene code. I haven't looked at example yet. By the way, I am a c++ programmer.
(If this comment was disrespectful, please report it.)

 
12/1/2000 8:51:08 PMelaias

For those of you that want to wrap you gray matter around ASM, you can go to the guru of ASM's online book at: http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/ArtofAsm.html . And for those of you who can't stay online you can follow the links to the main page and download the PS version.
(If this comment was disrespectful, please report it.)

 
1/7/2001 3:06:31 PMAnonymous

I think this code is horrible because I replaced your pictures with my own pictures, and when your program faded them, the pictures looked so bad, they looked all streached and corrupted.
(If this comment was disrespectful, please report it.)

 
4/14/2001 1:12:49 AMNick Behel

I saw your comment of explaining how this works in detail above. I have lately become interested in this type of stuff and would appreciate if you did explain it all. I got a solid 60 fps on my athlon950 w/gforce2 and 256megs of ram no problem. Great idea. nickbehel@aol.com
(If this comment was disrespectful, please report it.)

 
9/8/2001 3:24:05 AMeasfw

i must say this is truly fascinating. it's something i've been wanting to learn but looks too complicated
(If this comment was disrespectful, please report it.)

 
9/8/2001 3:26:38 AMeasfw

oh yeah i get about 9fps on this k6-2 500
(If this comment was disrespectful, please report it.)

 
2/7/2002 7:10:11 AMCod3r

Interesting hack, you have my respect.
(If this comment was disrespectful, please report it.)

 
3/10/2002 11:36:38 PMJames Dougherty

All I got to say is.... WHEW yes headache :) good job.. *ouch* -James-
(If this comment was disrespectful, please report it.)

 
3/26/2002 2:08:44 PMPhilip Kocanda

I am just started Visual Basic 6. I am always looking around on this site to find something nice to use in my app's and i found this! It is veary good!
Thanks!
(If this comment was disrespectful, please report it.)

 
5/13/2002 2:18:46 AMCarlos

usualy i d'ont vote but,
This one is AWESOME
(If this comment was disrespectful, please report it.)

 
7/5/2002 3:21:59 AMJim Dutcher

These techniques are obsolete. Assembly is ancient, please let go of the past...
(If this comment was disrespectful, please report it.)

 
7/16/2002 2:47:45 AMJosh Yu

Okay, Wow! ... I'll wallow myself in the code later.
(If this comment was disrespectful, please report it.)

 
9/8/2002 7:36:36 PMDavid Fritts

Jim Dutcher, your a crack head, assembly is still used today, all these other languages like VB and C++ are just compiled into an assembly, so plz shh and learn
(If this comment was disrespectful, please report it.)

 
12/3/2002 2:28:13 PM KamiElder

correction: VB is not compiled into asm :-)
(If this comment was disrespectful, please report it.)

 
12/13/2002 2:11:01 AMBarry Taylor

Excellent code mate, well done, i cant wait till im that good, how long does it take to become that good? email me the answer please and i will appreciate it ,
Thanks guys
(If this comment was disrespectful, please report it.)

 
6/2/2003 6:45:32 PMDavid J. Fritts

The computer only knows how to execute machine code, thus, every language is converted to machine code and then executed. This includes visual basic.
(If this comment was disrespectful, please report it.)

 
7/6/2003 1:42:21 AM

Your a God! I have been wanting this for a long time! You Rock!
(If this comment was disrespectful, please report it.)

 
12/13/2004 2:52:58 PMvampyr

great code! great frame rate.. but it would be faster if you wrote the whole prog in asm;)
(If this comment was disrespectful, please report it.)

 
5/26/2007 7:25:17 AMDavid

Cool.
What about fading text?
Any ideas?
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.