home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Mib / SPARKLE.ZIP / SPARKLE.ASM < prev    next >
Encoding:
Assembly Source File  |  1998-08-18  |  19.3 KB  |  730 lines

  1. ;Sparkle v1.0
  2. ;Written by Cruehead as the fouth part of the 1999 +HCU strainer
  3. ;TASM version
  4.  
  5. .386
  6. locals
  7. jumps
  8. .model flat,STDCALL
  9. include win32.inc           
  10. L equ <LARGE>
  11.  
  12. ID_TIMER        EQU 1
  13.  
  14. ;-------------------------------------------
  15. ; .-.-.- Begining of the DATA segment -.-.-.
  16. ;-------------------------------------------
  17.  
  18. .data
  19.  
  20. BrushHwnd         dd 0
  21. PenHwnd             dd 0
  22. MyHwnd              dd 0
  23. MyDC             dd 0
  24.  
  25. colourvalue         dd 0
  26. count2             dd 0
  27. counter             dd 0
  28. seed             dd 0
  29.  
  30. msg              MSGSTRUCT   <?>
  31. wc               WNDCLASS    <?>
  32. RC                 RECT         <?>
  33.  
  34. szNULL            db 0
  35. ymenu             dd 0
  36.  
  37. hInst            dd 0
  38. hMenu            dd 0
  39. hDlg             dd 0
  40.  
  41. szTitleName      db 'Sparkles, sparkles everywhere!',0
  42. szClassName      db 'ASMCLASS32',0
  43.  
  44. Colours             dd 000ff3131h                    ;Blue
  45.                  dd 000ff9595h                    ;Light blue
  46.                  dd 000ffffffh                    ;White
  47.                  dd 0000000c6h                    ;Red
  48.                  dd 0008a8affh                    ;Light red
  49.                  dd 000ffffffh                    ;White
  50.                  dd 00000a800h                    ;Green
  51.                  dd 00015ff15h                    ;Light green
  52.                  dd 000ffffffh                    ;White
  53.                  dd 0001562ffh                    ;Orange (the colour, not the fruit)
  54.                  dd 0006f9dffh                    ;Light orange
  55.                  dd 000ffffffh                    ;White
  56.  
  57. EllipsePara1     db 011h,011h,00Eh,00Eh            ;Here we save the parameters that we use 
  58.                  db 012h,012h,00Dh,00Eh            ;for the first ellipse
  59.                  db 014h,013h,00Ch,00Dh            ;We use four parameters for every time we call            
  60.                  db 015h,014h,00Bh,00Ch            ;the function, that's why I divided them
  61.                  db 016h,015h,009h,00Bh            ;like this
  62.                  db 017h,016h,008h,00Ah
  63.                  db 019h,016h,007h,009h
  64.                  db 01Ah,017h,006h,008h
  65.                  db 019h,016h,007h,009h
  66.                  db 017h,016h,008h,00Ah
  67.                  db 016h,015h,009h,00Bh
  68.                  db 015h,014h,00Bh,00Ch
  69.                  db 014h,013h,00Ch,00Dh
  70.                  db 012h,012h,00Dh,00Eh
  71.                  db 011h,011h,00Eh,00Eh
  72.  
  73. EllipsePara2     db 012h,011h,00Eh,00Fh            ;Same as above, but this time it's parameters
  74.                  db 013h,012h,00Dh,00Eh            ;for another ellipse
  75.                  db 014h,013h,00Bh,00Dh
  76.                  db 015h,014h,00Ah,00Ch
  77.                  db 017h,014h,009h,00Bh
  78.                  db 018h,015h,008h,00Ah
  79.                  db 017h,014h,009h,00Bh
  80.                  db 015h,014h,00Ah,00Ch
  81.                  db 014h,013h,00Bh,00Dh
  82.                  db 013h,012h,00Dh,00Eh
  83.                  db 012h,011h,00Eh,00Fh
  84.  
  85. EllipsePara3     db 012h,011h,00Dh,00Fh            ;And once again...parameters for the
  86.                  db 013h,012h,00Ch,00Eh            ;third ellipse
  87.                  db 015h,012h,00Bh,00Dh
  88.                   db 016h,013h,00Ah,00Ch
  89.                  db 015h,012h,00Bh,00Dh
  90.                  db 013h,012h,00Ch,00Eh
  91.                  db 012h,011h,00Dh,00Fh
  92.  
  93. MoveToExPara     db 0Fh,0Dh                        ;The parameters we'll need for the
  94.                  db 0Bh,0Fh                        ;"MoveToEx" function
  95.                  db 0Fh,0Dh
  96.                  db 0Ah,0Fh
  97.                  db 0Fh,0Ch
  98.                  db 09h,0Fh
  99.                  db 0Fh,0Bh
  100.                  db 08h,0Fh
  101.                  db 0Fh,0Ah
  102.                  db 06h,0Fh
  103.                  db 0Fh,09h
  104.                  db 05h,0Fh
  105.                  db 0Fh,08h
  106.                  db 04h,0Fh
  107.                  db 0Fh,07h
  108.                  db 03h,0Fh
  109.                  db 0Fh,08h
  110.                  db 04h,0Fh
  111.                  db 0Fh,09h
  112.                  db 05h,0Fh
  113.                  db 0Fh,0Ah
  114.                  db 06h,0Fh
  115.                  db 0Fh,0Bh
  116.                  db 08h,0Fh
  117.                  db 0Fh,0Ch
  118.                  db 09h,0Fh
  119.                  db 0Fh,0Dh
  120.                  db 0Ah,0Fh
  121.                  db 0Fh,0Dh
  122.                  db 0Bh,0Fh
  123.  
  124. LineToPara         db 00fh,012h                    ;Parameters that are used with the
  125.                  db 014h,00fh                    ;"LineToPara" function
  126.                  db 00fh,013h
  127.                  db 015h,00fh
  128.                  db 00fh,014h
  129.                  db 017h,00fh
  130.                  db 00fh,015h
  131.                  db 018h,00fh
  132.                  db 00fh,016h
  133.                  db 019h,00fh
  134.                  db 00fh,017h
  135.                  db 01ah,00fh
  136.                  db 00fh,017h
  137.                  db 01ch,00fh
  138.                  db 00fh,018h
  139.                  db 01dh,00fh
  140.                  db 00fh,017h
  141.                  db 01ch,00fh
  142.                  db 00fh,017h
  143.                  db 01ah,00fh
  144.                  db 00fh,016h
  145.                  db 019h,00fh
  146.                  db 00fh,015h
  147.                  db 018h,00fh
  148.                  db 00fh,014h
  149.                  db 017h,00fh
  150.                  db 00fh,013h
  151.                  db 015h,00fh
  152.                  db 00fh,012h
  153.                  db 014h,00fh
  154.                  
  155. ;--------------------------------------------------------------------------------------
  156. ;                       .-.-.- Code Segment starts here -.-.-.
  157. ;--------------------------------------------------------------------------------------
  158. ;
  159. ; Dont care to much for code that's undocumented, as they really havnt got anything
  160. ; to do with the real interesting part (the sparkle code that is)...If you're interested
  161. ; in Win32 ASM coding then I suppose it might be interesting to check out those
  162. ; functions as well...
  163. ;
  164. ;--------------------------------------------------------------------------------------
  165. .code
  166.  
  167. start:
  168.         push    L 0
  169.         call    GetModuleHandle         
  170.         mov     [hInst], eax            
  171.                                         
  172.         push    L 0
  173.         push    offset szClassName
  174.         call    FindWindow              ;More than one program opened?
  175.         or      eax,eax                 
  176.         jz      reg_class               
  177.         ret                             
  178.  
  179. reg_class:
  180.  
  181.         mov     [wc.clsStyle], CS_HREDRAW + CS_VREDRAW + CS_GLOBALCLASS
  182.         mov     [wc.clsLpfnWndProc], offset WndProc
  183.         mov     [wc.clsCbClsExtra], 0
  184.         mov     [wc.clsCbWndExtra], 0
  185.  
  186.         mov     eax, [hInst]
  187.         mov     [wc.clsHInstance], eax
  188.  
  189.         push    L IDC_ARROW             
  190.         push    L 0
  191.         call    LoadCursor
  192.         mov     [wc.clsHCursor], eax
  193.  
  194.         mov     [wc.clsHbrBackground], COLOR_BACKGROUND
  195.         mov     dword ptr [wc.clsLpszClassName], offset szClassName
  196.  
  197.         push    offset wc
  198.         call    RegisterClass
  199.  
  200.         push    L 0                              
  201.         push    [hInst]                          
  202.         push    L 0                              
  203.         push    L 0                              
  204.         push    L 290                               
  205.         push    L 280                               
  206.         push    L 150                            
  207.         push    L 170                            
  208.         push    L WS_OVERLAPPEDWINDOW            
  209.         push    offset szTitleName               
  210.         push    offset szClassName               
  211.         push    L 0                                   
  212.         call    CreateWindowEx
  213.         mov     [MyHwnd], eax
  214.  
  215.         push    [MyHwnd]
  216.         call    GetDC                            ;Get a Device Context for drawing purposes
  217.         mov        MyDC,eax                        ;We need one if we want to draw anything!
  218.                                                 
  219.         push    offset DrawProc
  220.         push    35                              ;A 35 ms timer
  221.         push    ID_TIMER                        ;Timer ID
  222.         push    [MyHwnd]                           ;Hwnd
  223.         call    SetTimer                        ;We'll use a timer to draw/remove anything
  224.                                                 ;on the screen.
  225.         push    L SW_SHOWNORMAL
  226.         push    [MyHwnd]
  227.         call    ShowWindow
  228.  
  229.         push    [MyHwnd]
  230.         call    UpdateWindow
  231.  
  232.         add esp,12
  233.  
  234.         call    GetTickCount                    ;Initialize seed value
  235.         mov     seed, eax                        ;Used to decide where on the screen we shall
  236.                                                 ;draw the sparkle.
  237.  
  238.         call    random                            ;Value returned in eax as well as in
  239.                                                 ;the variabel 'seed' is a random number
  240.  
  241.         and        al,00fh                            ;We delete everything in AL (which contains
  242.                                                 ;a random number) except the low part of it.
  243.                                                 ;That means that we'll have a value from 0-F
  244.                                                 ;saved in AL, and that's used when we choose
  245.                                                 ;a colour
  246.  
  247.         call    ChooseColour                    ;Chooses one of four colour. The decision is
  248.                                                 ;made by using the value in AL.
  249.                                                 ;Output returned in ebx (a value from 0-3)
  250.                                                 
  251.         lea        ebx,[ebx*2+ebx]                    ;Multiply ebx with three
  252.         shl        ebx,2                            ;and multiply this with 4
  253.                                                 ;So, bascily, ebx is multiplyed with 12.
  254.  
  255.         mov        colourvalue,ebx                    ;And saved away in a variable. 
  256.                                                 ;Why? Becuase it's used as a pointer in the
  257.                                                 ;"Colours" variable that hold all the colour
  258.                                                 ;values
  259.  
  260. ;-----------------------------------------------------
  261.  
  262. msg_loop:
  263.         push    L 0
  264.         push    L 0
  265.         push    L 0
  266.         push    offset msg
  267.         call    GetMessage
  268.  
  269.         cmp     ax, 0
  270.         je      end_loop
  271.  
  272.         push    offset msg
  273.         call    TranslateMessage
  274.  
  275.         push    offset msg
  276.         call    DispatchMessage
  277.  
  278.         jmp     msg_loop
  279.  
  280. end_loop:
  281.         push    [msg.msWPARAM]
  282.         call    ExitProcess             
  283.  
  284. ;-----------------------------------------------------
  285.  
  286. WndProc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
  287.         push    esi
  288.         push    edi
  289.         push    ebx
  290.         LOCAL   theDC:DWORD
  291.  
  292.         cmp     [wmsg], WM_DESTROY
  293.         je      wmdestroy
  294.         cmp     [wmsg], WM_SIZE
  295.         je      wmsize
  296.         cmp     [wmsg], WM_CREATE
  297.         je      wmcreate
  298.         jmp     defwndproc
  299.  
  300. wmcreate:
  301.         mov     eax, 0
  302.         jmp     finish
  303.  
  304. defwndproc:
  305.         push    [lparam]
  306.         push    [wparam]
  307.         push    [wmsg]
  308.         push    [hwnd]
  309.         call    DefWindowProc
  310.         jmp     finish
  311.  
  312. wmdestroy:
  313.  
  314.         push    [MyDC]                            ;We get to here when we quit, and then we
  315.         push    [MyHwnd]                        ;have to delete the DC so that Windows
  316.         call    ReleaseDC                        ;will deallocate memory for it
  317.  
  318.         push    ID_TIMER                        ;We have to destory the timer as well
  319.         push    [MyHwnd]
  320.         call    KillTimer
  321.  
  322.         push    L 0
  323.         call    PostQuitMessage
  324.         mov     eax, 0
  325.         jmp     finish
  326. wmsize:
  327.         mov     eax, 0
  328.         jmp     finish
  329.         
  330. finish:
  331.         pop     ebx                             ;Remember we must restore these registers
  332.         pop     edi                             ;because the OS need them
  333.         pop     esi
  334.         ret
  335. WndProc          endp
  336.  
  337. DrawProc proc
  338.         pusha                                    ;Just to make sure that we dont mess with
  339.                                                 ;any registers that the OS wants to use.
  340.  
  341.         call    RemoveOldPaint                    ;Remove what we have just painted
  342.         mov        ebx,colourvalue
  343.  
  344.         inc        counter
  345.         cmp        counter,15                        ;Have we drawn every bit of the sparkle?
  346.         jne        DrawSparkle                        ;If not, lets draw again
  347.  
  348.         mov        counter,0                        ;used as an innerloop counter
  349.  
  350.         call    random                            ;Fetch a random number, returned in EAX
  351.         and        al,00fh
  352.         call    ChooseColour                    ;Choose a colour
  353.  
  354.         lea        ebx,[ebx*2+ebx]
  355.         shl        ebx,2
  356.         mov        colourvalue,ebx                    ;Multiply EBX with 12 (you recognize this
  357.                                                 ;I hope...It's exactly that same as I have
  358.                                                 ;already described above)
  359.  
  360.         DrawSparkle:
  361.         push    dword ptr Colours[ebx]            ;ebx points to a colour value in the "colours"
  362.         push    0                                ;variable
  363.         push    PS_SOLID
  364.         call    CreatePen                        ;Here we say that will use the colour above
  365.         mov        PenHwnd,eax                        ;as the pen (that is used to draw the lines
  366.                                                 ;on the outermost ellipse)
  367.         push    [PenHwnd]
  368.         push    [MyDC]
  369.         call    SelectObject                    ;Select the pen into the device context
  370.  
  371.         push    eax                                ;Delete the previous saved pen in the
  372.         call    DeleteObject                    ;device context to deallocate memory
  373.  
  374.         push    dword ptr Colours[ebx]            ;Create a colour to fill the outermost ellipse
  375.         call    CreateSolidBrush
  376.         mov        BrushHwnd,eax
  377.  
  378.         push    [BrushHwnd]
  379.         push    [MyDC]
  380.         call    SelectObject                    ;Select the brush we just created in the 
  381.                                                 ;device context.
  382.  
  383.         push    eax                                ;And as usuall, delete the previous brush
  384.         call    DeleteObject
  385.  
  386.         call    DrawEllipse1                    ;Draws the first ellipse
  387.         mov        ebx,colourvalue
  388.  
  389.         cmp        counter,2                        ;Are we going to draw another ellipse?
  390.         jb        NoMoreEllipses                    ;If we are, dont take the jump
  391.                                                 ;It all depends on how many times we have gone
  392.                                                 ;through this loop
  393.  
  394.         cmp        counter,13                        ;The same question here...
  395.         ja        NoMoreEllipses
  396.  
  397.         cmp        counter,4                        ;Here we decide what colour this ellipse will
  398.         jae        PushOtherColour                    ;have. As above, it depends on how many times
  399.                                                 ;we have gone through the loop
  400.  
  401.         cmp        counter,10                        ;Same question here...
  402.         ja        PushOtherColour
  403.  
  404.         push    dword ptr Colours[ebx+8]        ;Use a white colour for the pen
  405.         push    0
  406.         push    PS_SOLID
  407.         call    CreatePen
  408.         mov        PenHwnd,eax
  409.  
  410.         push    [PenHwnd]
  411.         push    [MyDC]
  412.         call    SelectObject
  413.  
  414.         push    eax
  415.         call    DeleteObject
  416.  
  417.         push    dword ptr Colours[ebx+8]        ;Use a white colour for the brush
  418.         call    CreateSolidBrush
  419.         mov        BrushHwnd,eax
  420.         jmp        GoHere
  421.         
  422.         PushOtherColour:
  423.  
  424.         push    dword ptr Colours[ebx+4]        ;Use a light shade of the colour for the pen
  425.         push    0
  426.         push    PS_SOLID
  427.         call    CreatePen
  428.         mov        PenHwnd,eax
  429.  
  430.         push    [PenHwnd]
  431.         push    [MyDC]
  432.         call    SelectObject
  433.  
  434.         push    eax
  435.         call    DeleteObject
  436.  
  437.         push    dword ptr Colours[ebx+4]        ;Use a light shade of the colour for the brush
  438.         call    CreateSolidBrush
  439.         mov        BrushHwnd,eax
  440.  
  441.         GoHere:
  442.  
  443.         push    [BrushHwnd]
  444.         push    [MyDC]
  445.         call    SelectObject
  446.  
  447.         push    eax
  448.         call    DeleteObject
  449.  
  450.         call    DrawEllipse2                    ;Draws the second ellipse
  451.         mov        ebx,colourvalue
  452.  
  453.         cmp        counter,4                        ;Once more, the question is - shall we draw
  454.         jb        NoMoreEllipses                    ;another ellipse?
  455.  
  456.         cmp        counter,10                        ;Same question
  457.         ja        NoMoreEllipses
  458.  
  459.         push    dword ptr Colours[ebx+8]        ;Create a white pen for the third ellipse
  460.         call    CreateSolidBrush
  461.         mov        BrushHwnd,eax                    
  462.  
  463.         push    [BrushHwnd]
  464.         push    [MyDC]
  465.         call    SelectObject        
  466.  
  467.         push    eax
  468.         call    DeleteObject
  469.  
  470.         push    dword ptr Colours[ebx+8]        ;Create a white brush for the third ellipse
  471.         push    0
  472.         push    PS_SOLID
  473.         call    CreatePen
  474.         mov        PenHwnd,eax
  475.  
  476.         push    [PenHwnd]
  477.         push    [MyDC]
  478.         call    SelectObject
  479.  
  480.         push    eax
  481.         call    DeleteObject
  482.  
  483.         call    DrawEllipse3                    ;Draw the third ellipse
  484.         mov        ebx,colourvalue
  485.  
  486.         NoMoreEllipses:
  487.  
  488.         push    0ffffffh                        ;Create a white pen, used for drawing lines
  489.         push    0
  490.         push    PS_SOLID        
  491.         call    CreatePen
  492.         mov        PenHwnd,eax
  493.  
  494.         push    [PenHwnd]
  495.         push    [MyDC]
  496.         call    SelectObject
  497.  
  498.         push    eax
  499.         call    DeleteObject
  500.  
  501.         call    DrawLines                        ;Draws the lines in the ellipse(es)
  502.         mov        ebx,colourvalue
  503.  
  504.         push    [BrushHwnd]
  505.         call    DeleteObject
  506.  
  507.         push    [PenHwnd]                        ;We have to clean up the mess we created
  508.         call    DeleteObject                    ;before we quit
  509.  
  510.         popa                                    ;Restore the registers
  511.         ret    
  512. DrawProc endp
  513.  
  514. ;----------------------------------------------------------------
  515. ; Here comes all the functions that are called from the main code
  516. ;----------------------------------------------------------------
  517.  
  518. ChooseColour:
  519.         cmp        al,03h                            ;If AL 0-3 then we'll use a blue colour
  520.         ja        notblue
  521.         mov        ebx,0
  522.         jmp        gotcolour
  523.         notblue:
  524.         cmp        al,07h                            ;If AL 4-7 then we'll use a red colour
  525.         ja        notred
  526.         mov        ebx,1
  527.         jmp        gotcolour
  528.         notred:
  529.         cmp        al,0bh                            ;If Al 8-11 then we'll use a green colour
  530.         ja        notgreen
  531.         mov        ebx,2
  532.         jmp        gotcolour
  533.         notgreen:
  534.         mov        ebx,3                            ;If Al is non of the above (that means that
  535.         gotcolour:                                ;AL must be 12-15) then we'll use 
  536.                                                 ;an orange colour
  537.  
  538.                                                 ;The value in ebx represent the colour.
  539.                                                 ;0 - blue
  540.                                                 ;1 - red
  541.                                                 ;2 - green
  542.                                                 ;3 - orange
  543. ret
  544.  
  545. DrawEllipse1:
  546.         xor        eax,eax
  547.         mov        ebx,counter                        ;Multiply with four, as there are four
  548.         shl        ebx,2                            ;parameters
  549.         mov        edx,seed                        ;Use the lower part of SEED once again to
  550.         and        edx,0ffh                        ;decide where on the screen we shall draw
  551.         mov        al,byte ptr EllipsePara1[ebx]   ;EBX is a pointer in the "EllipsePara1" varaible
  552.         add        ax,dx                            ;that points to the parameter that we'll use.
  553.         push    eax
  554.         mov        al,byte ptr EllipsePara1[ebx+1]    ;Get the second parameter
  555.         add        ax,dx                            ;add DX to AX in order to draw the sparkle
  556.         push    eax                                ;on a random place on the screen
  557.         mov        al,byte ptr EllipsePara1[ebx+2] ;Get the third parameter
  558.         add        ax,dx
  559.         push    eax
  560.         mov        al,byte ptr EllipsePara1[ebx+3] ;Get the fourth parameter
  561.         add        ax,dx
  562.         push    eax
  563.         push    [MyDC]                            ;Push the Devide Context
  564.         call    Ellipse                            ;And draw the ellipse!
  565. ret
  566.  
  567. DrawEllipse2:
  568.         xor        eax,eax                            ;Look at the comments on "DrawEllipse1" 
  569.         mov        ebx,counter                        ;as the functions are pretty much the same
  570.         sub        ebx,2                            ;just different parameters
  571.         shl        ebx,2
  572.         mov        edx,seed
  573.         and        edx,0ffh
  574.         mov        al,byte ptr EllipsePara2[ebx]
  575.         add        ax,dx
  576.         push    eax
  577.         mov        al,byte ptr EllipsePara2[ebx+1]
  578.         add        ax,dx
  579.         push    eax
  580.         mov        al,byte ptr EllipsePara2[ebx+2]
  581.         add        ax,dx
  582.         push    eax
  583.         mov        al,byte ptr EllipsePara2[ebx+3]
  584.         add        ax,dx
  585.         push    eax
  586.         push    [MyDC]
  587.         call    Ellipse
  588. ret
  589.  
  590. DrawEllipse3:
  591.         xor        eax,eax                            ;Look at the comments on "DrawEllipse1"
  592.         mov        ebx,counter                        ;As the functions are pretty much the same
  593.         sub        ebx,4                            ;just different parameters
  594.         shl        ebx,2
  595.         mov        edx,seed
  596.         and        edx,0ffh
  597.         mov        al,byte ptr EllipsePara3[ebx]
  598.         add        ax,dx
  599.         push    eax
  600.         mov        al,byte ptr EllipsePara3[ebx+1]
  601.         add        ax,dx
  602.         push    eax
  603.         mov        al,byte ptr EllipsePara3[ebx+2]
  604.         add        ax,dx
  605.         push    eax
  606.         mov        al,byte ptr EllipsePara3[ebx+3]
  607.         add        ax,dx
  608.         push    eax
  609.         push    [MyDC]
  610.         call    Ellipse
  611. ret
  612.  
  613. RemoveOldPaint:
  614.         push    0ffffffh
  615.         push    0
  616.         push    PS_SOLID
  617.         call    CreatePen
  618.         mov        PenHwnd,eax
  619.  
  620.         push    [PenHwnd]
  621.         push    [MyDC]
  622.         call    SelectObject
  623.  
  624.         push    eax        
  625.         call    DeleteObject                    ;Everytime we select a new object we have
  626.                                                 ;to delete the old one, otherwise windows
  627.                                                 ;wont deallocate memory!
  628.         push    0c0c0c0h                    
  629.         Call    CreateSolidBrush
  630.         mov        BrushHwnd,eax
  631.  
  632.         mov        edx,seed
  633.         and        edx,0ffh                        ;the low part of the "seed" variable is used
  634.                                                 ;as "where on screen will we draw". That way
  635.                                                 ;we get the sparkles to move around.
  636.         mov        RC.left,edx
  637.         mov        RC.top,edx
  638.         add        dx,020h
  639.         mov        RC.right,edx
  640.         mov        RC.bottom,edx
  641.     
  642.         push    [BrushHwnd]                        ;Handle for the brush
  643.         push    offset RC
  644.         push    [MyDC]
  645.         call    FillRect                        ;Fill a rectange with the background value
  646.                                                 ;Thus removing anything we might have painted
  647.                                                 ;there before.
  648. ret
  649.  
  650. DrawLines:
  651.         xor        eax,eax
  652.         mov        ebx,counter    
  653.         lea        ebx,[ebx*2]
  654.         shl        ebx,1                            ;Multiply with four as there are two
  655.         push    0                                ;parameters for each "MoveToEx" function
  656.         mov        edx,seed                        ;and there are 2 MoveToEx functions
  657.         and        edx,0ffh
  658.         mov        al,byte ptr MoveToExPara[ebx]
  659.         add        ax,dx
  660.         push    eax
  661.         mov        al,byte ptr MoveToExPara[ebx+1]
  662.         add        ax,dx
  663.         push    eax
  664.         push    [MyDC]
  665.         call    MoveToEx
  666.  
  667.         xor        eax,eax
  668.         mov        ebx,counter
  669.         shl        ebx,2                            ;Same as above, multiply with four as
  670.         mov        edx,seed                        ;there are two parameters for each "LineTo"
  671.         and        edx,0ffh                        ;function, and there are 2 of them
  672.         mov        al,byte ptr LineToPara[ebx]
  673.         add        ax,dx
  674.         push    eax
  675.         mov        al,byte ptr LineToPara[ebx+1]
  676.         add        ax,dx
  677.         push    eax
  678.         push    [MyDC]
  679.         call    LineTo
  680.  
  681.         xor        eax,eax                            ;Here begins the second "MoveToEx" function
  682.         mov        ebx,counter    
  683.         lea        ebx,[ebx*2]
  684.         shl        ebx,1
  685.         push    0
  686.         mov        edx,seed
  687.         and        edx,0ffh
  688.         mov        al,byte ptr MoveToExPara[ebx+2]
  689.         add        ax,dx        
  690.         push    eax
  691.         mov        al,byte ptr MoveToExPara[ebx+3]
  692.         add        ax,dx
  693.         push    eax
  694.         push    [MyDC]
  695.         call    MoveToEx
  696.  
  697.         xor        eax,eax                            ;Here begins the second "LineTo" function
  698.         mov        ebx,counter
  699.         shl        ebx,2
  700.         mov        edx,seed
  701.         and        edx,0ffh
  702.         mov        al,byte ptr LineToPara[ebx+2]
  703.         add        ax,dx
  704.         push    eax
  705.         mov        al,byte ptr LineToPara[ebx+3]
  706.         add        ax,dx
  707.         push    eax
  708.         push    [MyDC]
  709.         call    LineTo
  710. ret
  711.  
  712. ;Used to choose colour, and to draw the sparkle
  713. ;on a somewhat random place on the screen
  714.  
  715. random:                                            ;Ok, I stole the begining of this routine from
  716.         mov     eax, 214013                        ;another program. Sorry, but I cant remember
  717.         imul    seed                            ;the name of it. Anyway, this routine returnes
  718.         xor        edx,edx                            ;a random value in the variable "seed", as well
  719.         add     eax, 2531011                    ;as in EAX.
  720.         cmp        al,0e2h                            
  721.         jb        noproblemo                        
  722.         add        al,01eh                            ;Just a small fix, otherwise it wouldnt look
  723.         noproblemo:                                ;very nice...dont worry (be happy :)) about it
  724.         mov     seed, eax
  725.         ret
  726. ret
  727.  
  728. public WndProc
  729. end start
  730.