News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WinFire Demo

Started by avcaballero, October 18, 2012, 08:55:57 PM

Previous topic - Next topic

avcaballero

Win Fire Demo. I believe it is pretty beautiful, only left system metrics. Regards.

Vortex

Nice demo but it consumes 50% processor power. ( CPU = Pentium IV , 3.2 Ghz )

I guess your application is performing some heavy calculations.

dedndave

when you are done handling WM_CREATE, WM_DESTROY, WM_PAINT, and WM_TIMER....
you should return 0 in EAX

avcaballero

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 and, please, tell me anything.

Regards

dedndave

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:

avcaballero

Ah, interesting, this is what I meant by *avoiding SetPixel*. I need a while to savor CreateDIBSection, but looks great. Thank you very much.

TouEnMasm

Fa is a musical note to play with CL

avcaballero

Please, reread some post above at "you can download from here"....

TouEnMasm

Thanks,
Your one is very similar with the "108_Fire.zip" that can be found in the "archive 2" of the forum ,Not ?.

Fa is a musical note to play with CL

TouEnMasm

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
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
Here the result,who consume a lesser time of the processor /2

Fa is a musical note to play with CL

dedndave

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

;***********************************************************************************************

TouEnMasm


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.
Fa is a musical note to play with CL

dedndave

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

TouEnMasm

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.
Fa is a musical note to play with CL

dedndave

well - it IS a processor intensive demo, also   :biggrin: