Win Fire Demo. I believe it is pretty beautiful, only left system metrics. Regards.
Nice demo but it consumes 50% processor power. ( CPU = Pentium IV , 3.2 Ghz )
I guess your application is performing some heavy calculations.
when you are done handling WM_CREATE, WM_DESTROY, WM_PAINT, and WM_TIMER....
you should return 0 in EAX
Quote from: Vortex on October 19, 2012, 05:39:59 AM
I guess your application is performing some heavy calculations.
Not really, of course it is multibuffer, does anyone know any other way?
Quote from: dedndave on October 19, 2012, 04:07:24 PM
when you are done handling WM_CREATE, WM_DESTROY, WM_PAINT, and WM_TIMER....
you should return 0 in EAX
I believe that it doesn't work, in fact, the trick WM_ERASEBKGND[eax=1] doesn't work too.
For sure that the code can be optimized. The first question that I make to myself is if is there any way to avoid SetPixel (always slow) in MSDOS we cuould do it using direct memory accesing, I need to investigate if we can do the same with GDI, any suggestion?
If anyone is interested in the code to try optimization, please, you can download from here (http://www.abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap20.html#WinFire) and, please, tell me anything.
Regards
there sure is
you can use CreateDIBSection to get a HBITMAP and a pointer to the image data :t
much faster than SetPixel
select the HBITMAP into the hDC to paint
and use the pvBits pointer to alter the data
as for returning 0...
try this
WndProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL ps: PAINTSTRUCT
mov eax,uMsg
.if eax==WM_TIMER
;timer code here
xor eax,eax ;return 0
.elseif eax==WM_PAINT
INVOKE BeginPaint,hWnd,addr ps
;paint code here
INVOKE EndPaint,hWnd,addr ps
xor eax,eax ;return 0
.elseif eax==WM_DESTROY
;destroy code here
xor eax,eax ;return 0
.elseif eax==WM_CREATE
;create code here
xor eax,eax ;return 0
.else
INVOKE DefWindowProc,hWnd,uMsg,wParam,lParam
.endif
ret
WndProc ENDP
the fire looks really nice, by the way :biggrin:
Ah, interesting, this is what I meant by *avoiding SetPixel*. I need a while to savor CreateDIBSection, but looks great. Thank you very much.
No source code ?
Please, reread some post above at "you can download from here"....
Thanks,
Your one is very similar with the "108_Fire.zip" that can be found in the "archive 2" of the forum ,Not ?.
I have made a search on the old forum and find all the pieces of codes of the project.
The author is dougiem and is last post
http://www.masmforum.com/board/index.php?topic=918.msg6511#msg6511 (http://www.masmforum.com/board/index.php?topic=918.msg6511#msg6511)
Say there is an update version of gdiplus_structures_ver0.inc (not found)
I have not find all the include but the "ready to use sdk" had made the rest
http://masm32.com/board/index.php?topic=563.msg4563#msg4563 (http://masm32.com/board/index.php?topic=563.msg4563#msg4563)
Here the result,who consume a lesser time of the processor /2
here is some code that creates a 24-bit DIB section and a DC and selects the DIB into the DC
when you are done using it, the ReleaseDIB24 routine will do the cleanup
;equates
DIB_WIDTH EQU 1024
DIB_HEIGHT EQU 768
;
;
;
.DATA?
pvBits LPVOID ? ;pvBits is a pointer to the image data (first byte of bottom line)
hbmpDIB HBITMAP ?
hdcDIB HDC ?
hbmpDIBDC HBITMAP ?
;
;
;
.CODE
;**********************************************************************************************
CreateDIB24 PROC USES EDI
LOCAL bmis :BITMAPINFO
; bmiHeader BITMAPINFOHEADER <>
; biSize dd ?
; biWidth dd ?
; biHeight dd ?
; biPlanes dw ?
; biBitCount dw ?
; biCompression dd ?
; biSizeImage dd ?
; biXPelsPerMeter dd ?
; biYPelsPerMeter dd ?
; biClrUsed dd ?
; biClrImportant dd ?
;-----------------------------------------
mov edx,DIB_HEIGHT
mov eax,DIB_WIDTH
xor edi,edi ;EDI = 0
mov bmis.bmiHeader.biHeight,edx
mov bmis.bmiHeader.biWidth,eax
mov bmis.bmiHeader.biSize,sizeof BITMAPINFOHEADER ;28h
imul eax,3
mov bmis.bmiHeader.biPlanes,1
add eax,3
and eax,-4 ;EAX = bytes per line
mov bmis.bmiHeader.biBitCount,24
mul edx ;EAX = total image data bytes
mov bmis.bmiHeader.biCompression,edi ;BI_RGB = 0
mov bmis.bmiHeader.biSizeImage,eax
mov bmis.bmiHeader.biXPelsPerMeter,edi
mov bmis.bmiHeader.biYPelsPerMeter,edi
mov bmis.bmiHeader.biClrUsed,edi
mov bmis.bmiHeader.biClrImportant,edi
INVOKE GetDC,edi ;HWND_DESKTOP = 0
xchg eax,edi ;EDI = hdcDesktop, EAX = 0
INVOKE CreateDIBSection,edi,addr bmis,DIB_RGB_COLORS,offset pvBits,eax,eax
mov hbmpDIB,eax
INVOKE CreateCompatibleDC,edi
mov hdcDIB,eax
INVOKE SelectObject,eax,hbmpDIB
mov hbmpDIBDC,eax
INVOKE ReleaseDC,HWND_DESKTOP,edi
ret
CreateDIB24 ENDP
;***********************************************************************************************
ReleaseDIB24 PROC
INVOKE SelectObject,hdcDIB,hbmpDIBDC ;EAX = hbmpDIB
INVOKE DeleteObject,eax
INVOKE DeleteDC,hdcDIB
xor eax,eax
mov hbmpDIB,eax
mov hdcDIB,eax
ret
ReleaseDIB24 ENDP
;***********************************************************************************************
seems there is a shut down on this post.The goal is to decrease the processor used time under 50%.
use alt-ctrl-del (task manager) to view that.
i think returning 0 in EAX will help
but - also, using SetPixel is probably killing the processor usage
each call to SetPixel creates and destroys a DIB section to modify a single pixel
Quote
think returning 0 in EAX will help
but - also, using SetPixel is probably killing the processor usage
In the sample i have posted,the windows loop is perfect,return 0 in eax,when it's needed.
The SetPixel function is not used.
well - it IS a processor intensive demo, also :biggrin:
Quote from: ToutEnMasm on October 20, 2012, 12:28:36 AM
Thanks,
Your one is very similar with the "108_Fire.zip" that can be found in the "archive 2" of the forum ,Not ?.
Don't know, but it is possible. The algorithm I have used is one I have found several years ago from a Turbo Pascal source code (that's the season why it is 320x200 size), it was the best of all I saw... Unfortunately I lost the code and with it its author name... this is the reason why he is not in my bibliography (http://www.abreojosensamblador.net/Productos/AOE/html/Pags_en/Bibliography.html)
In addition, I had planned to publish the result of applying the function CreateDIBSection, I thought that it had gotten pretty clean and didactic. By the way, great discovery, using it, the program does not practically consume resources of the system. Believe me, practically nothing. But, since you already have one, I have better holding it for me.
Using eax = 0, I believe that does no fix the problem.
(http://www.abreojosensamblador.net/Productos/AOE/html/Imags/Cap20/Resources.png)
Quote
Believe me, practically nothing. But, since you already have one, I have better holding it for me.
I see a top secret code,perhaps ist it money in it ? :lol:
Just a simple code showing fast method for display.
It will be interesting to have it here,or with a link on it.
:biggrin:
i am reminded of the "Secret Sam" briefcase i had when i was a kid - lol
(http://img13.imageshack.us/img13/7029/cfa712.jpg)
as though noone else knew it was a secret sam briefcase 8)
Let's see, didn't you have already one code that solved the problem? Your fire program does not consume resources in my task manager... Too much instructions for a kid, isn't it? :greensml:
As Dedndave said, I think that is probably that the SetPixel function be the key.
I have updated my site, hence the source code is where before (http://www.abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap20.html#WinFire), explained. There's also a subroutine to fit the main window round the image size and center it raising a bit.
Regards
You are right on this:
The WAFire_03.exe is a real good demo program with is source code.
But this need to be discuss:
Quote
Let's see, didn't you have already one code that solved the problem? Your fire program does not consume resources in my task manager... Too much instructions for a kid, isn't it?
I don't pretend than the code i re-published solved the problem.I am just a newbe on this matter.
Your WAFire_03.exe is the best,I am happy to claim it here.
when i click on those links to download either the source or the binary,
i get a blank page that appears to be a 404 not found html
Another trick to be more mysterious.
You need to go at the bottom of the page reading the commentS.
[url]
http://www.abreojosensamblador.net/Productos/AOE/html/Codigos/Cap20/16-WinDemos/Fuego/WAFire_03.exe
/url]
thanks Yves :t
Here a translate for masm
Quote from: dedndave on October 23, 2012, 05:13:47 AM
when i click on those links to download either the source or the binary,
i get a blank page that appears to be a 404 not found html
I'm sorry, are the drawbacks of being on live.
Quote from: ToutEnMasm on October 23, 2012, 06:03:36 PM
Here a translate for masm
Nice, if you do not mind, I can also hang masm version, if you want I can include your name/pseudonym (the latter is sufficient if you want) as the author of the translation to masm.
Ops. One thing, mdat should be unitialized, otherwise, the executable will be too big.
Regards
I have changed mdat to unitialised data.
The difference of size is notable.
Quote
Nice, if you do not mind, I can also hang masm version, if you want I can include your name/pseudonym (the latter is sufficient if you want) as the author of the translation to masm.
OK,ToutEnMasm is perfect
Hi ToutEnMasm,
Your version of WinFire works fine and it does not suffer from high processor usage.
I have uploaded the masm version. I have modified several things from yours:
* Unitialized some variables
* Deleted some parameters that really are not needed
* Changed tabs by spaces. I can't read code with tabs.
* Deleted some things that I really don't know what are they for.
* Changed structures to what I usually use.
* Some other minor things
Regards
Your improved version works fine now, thanks :t
Quote
miPaleta stPaleta 4*256 dup(<>)
It's over dimensionned
Quote
miPaleta stPaleta 256 dup(<>) ;is enough
[hwnd] and so on aren't needed,mean adress and work only because there is a prototype.What is passed is a value.
Thank you, ToutEnMasm