1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
| ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Ë®²šÐ§¹û¹«ÓÃ×Ó³ÌÐò
; by ÂÞÔƱò£¬http://asm.yeah.net£¬luoyunbin@sina.com
; V 1.0.041019 --- ³õÊŒ°æ±Ÿ
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ÔÚÔŽŽúÂëÖÐÖ»ÐèÒª include WaveObject.asm
; È»ºó°ŽÒÔϲœÖèµ÷ÓÃŒŽ¿É£º
;********************************************************************
; 1¡¢ŽŽœšË®²š¶ÔÏó£º
; Òª¶ÔÒ»žöŽ°¿ÚœøÐл滣¬Ê×ÏÈÒªŽŽœšÒ»žöË®²š¶ÔÏ󣚱Ÿº¯ÊýÉêÇëһЩ»º³åÇø£©
; invoke _WaveInit,lpWaveObject,hWnd,hBmp,dwTime,dwType
; lpWaveObject --> ÖžÏòÒ»žö¿ÕµÄ WAVE_OBJECT œá¹¹
; hWnd --> Òª»æ»Ë®²šÐ§¹ûµÄŽ°¿Ú£¬äÖÈŸºóµÄ͌Ƭœ«»µœŽ°¿ÚµÄ¿Í»§ÇøÖÐ
; hBmp --> ±³Ÿ°ÍŒÆ¬£¬»æ»µÄ·¶Î§ŽóСͬ±³Ÿ°ÍŒÆ¬ŽóС
; dwTime --> ˢеÄʱŒäŒäžô£šºÁÃ룩£¬œšÒéÖµ£º10¡«30
; dwType --> =0 ±íÊŸÔ²ÐÎË®²š£¬=1±íÊŸÍÖÔ²ÐÍË®²š£šÓÃÓÚÍžÊÓЧ¹û£©
; ·µ»ØÖµ£ºeax = 0£š³É¹Š£¬¶ÔÏó±»³õÊŒ»¯£©£¬eax = 1£šÊ§°Ü£©
;********************************************************************
; 2¡¢Èç¹û _WaveInit º¯Êý·µ»Ø³É¹Š£¬Ôò¶ÔÏó±»³õÊŒ»¯£¬œ«¶ÔÏóŽ«žøÏÂÁО÷ÖÖº¯Êý
; ¿ÉÒÔʵÏÖž÷ÖÖЧ¹û£¬ÏÂÃ溯ÊýÖÐµÄ lpWaveObject ²ÎÊýÖžÏòÔÚ _WaveInit º¯Êý
; ÖгõÊŒ»¯µÄ WAVE_OBJECT œá¹¹
;
; ¡ò ÔÚÖž¶šÎ»Öá°ÈÓʯͷ¡±£¬Œ€ÆðË®²š
; invoke _WaveDropStone,lpWaveObject,dwPosX,dwPosY,dwStoneSize,dwStoneWeight
; dwPosX,dwPosY --> ÈÓÏÂʯͷµÄλÖÃ
; dwStoneSize --> ʯͷµÄŽóС£¬ŒŽ³õÊŒµãµÄŽóС£¬œšÒéÖµ£º0¡«5
; dwStoneWeight --> ʯͷµÄÖØÁ¿£¬Ÿö¶šÁ˲š×îºóÀ©É¢µÄ·¶Î§ŽóС£¬œšÒéÖµ£º10¡«1000
;
; ¡ò ×Ô¶¯ÏÔÊŸÌØЧ
; invoke _WaveEffect,lpWaveObject,dwEffectType,dwParam1,dwParam2,dwParam3
; dwParam1,dwParam2,dwParam3 --> Ч¹û²ÎÊý£¬¶Ô²»Í¬µÄÌØЧÀàÐͲÎÊýº¬Ò岻ͬ
; dwEffectType --> ÌØЧÀàÐÍ
; 0 --> ¹Ø±ÕÌØЧ
; 1 --> ÏÂÓ꣬Param1£œÃÜŒ¯Ëٶȣš0×îÃÜ£¬ÔœŽóԜϡÊ裩£¬œšÒéÖµ£º0¡«30
; Param2£œ×îŽóÓêµãÖ±Ÿ¶£¬œšÒéÖµ£º0¡«5
; Param3£œ×îŽóÓêµãÖØÁ¿£¬œšÒéÖµ£º50¡«250
; 2 --> Æûͧ£¬Param1£œËٶȣš0×îÂý£¬ÔœŽóÔœ¿ì£©£¬œšÒéÖµ£º0¡«8
; Param2£œŽ¬ŽóС£¬œšÒéÖµ£º0¡«4
; Param3£œË®²šÀ©É¢µÄ·¶Î§£¬œšÒéÖµ£º100¡«500
; 3 --> ·çÀË£¬Param1£œÃܶȣšÔœŽóÔœÃÜ£©£¬œšÒéÖµ£º50¡«300
; Param2£œŽóС£¬œšÒéÖµ£º2¡«5
; Param3£œÄÜÁ¿£¬œšÒéÖµ£º5¡«10
;
; ¡ò Ž°¿Ú¿Í»§ÇøÇ¿ÖÆžüУšÓÃÓÚÔÚŽ°¿ÚµÄWM_PAINTÏûÏ¢ÖÐÇ¿ÖÆžüпͻ§¶Ë£©
; .if uMsg == WM_PAINT
; invoke BeginPaint,hWnd,addr @stPs
; mov @hDc,eax
; invoke _WaveUpdateFrame,lpWaveObject,eax,TRUE
; invoke EndPaint,hWnd,addr @stPs
; xor eax,eax
; ret
;********************************************************************
; 3¡¢ÊÍ·ÅË®²š¶ÔÏó£º
; ʹÓÃÍê±Ïºó£¬±ØÐ뜫ˮ²š¶ÔÏóÊÍ·Å£š±Ÿº¯Êýœ«ÊÍ·ÅÉêÇëµÄ»º³åÇøÄÚŽæµÈ×ÊÔŽ£©
; invoke _WaveFree,lpWaveObject
; lpWaveObject --> ÖžÏò WAVE_OBJECT œá¹¹
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ʵÏÖÉϵÄÏžœÚ˵Ã÷£º
;
; 1¡¢ Ë®²šµÄÌØÕ÷£º
; ¡ò À©É¢£ºÃ¿Ò»µãµÄ²š»áÀ©É¢µœÆäËÄÖܵÄλÖÃÖÐ
; ¡ò Ë¥Œõ£ºÃ¿ŽÎÀ©É¢»áËðʧÉÙÁ¿ÄÜÁ¿£š·ñÔòË®²š»áÓÀ²»Í£Ö¹µÄÕðµŽÏÂÈ¥£©
;
; 2¡¢ ΪÁ˱£ŽæÁœžöʱ¿ÌÖеÄÄÜÁ¿·Ö²œÍŒ£¬¶ÔÏóÖжšÒå2žö»º³åÇøWave1ºÍWave2
; £š±£ŽæÔÚlpWave1ºÍlpWave2ÖžÏòµÄ»º³åÇøÄÚ£©£¬Wave1Ϊµ±Ç°ÊýŸÝ£¬Wave2Ϊ
; ÉÏÒ»Ö¡µÄÊýŸÝ£¬Ã¿ŽÎäÖȟʱœ«žùŸÝÉÏÃæµÄ2žöÌØÕ÷£¬ÓÉWave1µÄÊýŸÝŒÆËã³öÐÂ
; ÄÜÁ¿·Ö±ðÍŒºó£¬±£ŽæµœWave2ÖУ¬È»ºóµ÷»»Wave1ºÍWave2£¬ÕâʱWave1ÈÔÊÇ×î
; еÄÊýŸÝ¡£
; ŒÆËãµÄ·œ·šÎª£¬Ä³žöµãµÄÄÜÁ¿£œµãËÄÖܵÄÉÏŽÎÄÜÁ¿µÄÆœŸùÖµ * Ë¥ŒõϵÊý
; È¡ËÄÖܵÄÆœŸùÖµ±íÏÖÁËÀ©Õ¹ÌØÕ÷£¬³ËÒÔË¥ŒõϵÊý±íÏÖÁËË¥ŒõÌØÕ÷¡£
; Õⲿ·ÖŽúÂëÔÚ _WaveSpread ×Ó³ÌÐòÖÐʵÏÖ¡£
;
; 3¡¢ ¶ÔÏóÔÚ lpDIBitsSource Öб£ŽæÁËÔʌλ͌µÄÊýŸÝ£¬Ã¿ŽÎäÖȟʱ£¬ÓÉÔÊŒ
; λ͌µÄÊýŸÝžùŸÝWave1Öб£ŽæµÄÄÜÁ¿·Ö²œÊýŸÝ²úÉúеÄλ͌¡£ŽÓÊÓŸõÉÏ¿Ž£¬
; ijžöµãµÄÄÜÁ¿ÔœŽó£šË®²šÔœŽó£©£¬Ôò¹âÏßÕÛÉä³öԜԶŽŠµÄ³¡Ÿ°¡£
; Ë㷚Ϊ£º¶ÔÓڵ㣚x,y£©£¬ÔÚWave1ÖÐÕÒ³öžÃµã£¬ŒÆËã³öÏàÁÚµãµÄ²šÄܲî
; £šDxºÍDyÁœžöÊýŸÝ£©£¬ÔòÐÂλ͌ÏñËØ£šx,y£©£œÔʌλ͌ÏñËØ£šx+Dx,y+Dy£©£¬
; žÃËã·š±íÏÖÁËÄÜÁ¿ŽóСӰÏìÁËÏñËØÕÛÉäµÄÆ«ÒÆŽóС¡£
; Õⲿ·ÖŽúÂëÔÚ _WaveRender ×Ó³ÌÐòÖÐʵÏÖ¡£
;
; 4¡¢ ÈÓʯͷµÄËã·šºÜºÃÀíœâ£¬ŒŽœ«Wave1ÖеÄijžöµãµÄÄÜÁ¿ÖµÖÃΪ·Ç0Öµ£¬ÊýÖµ
; ÔœŽó£¬±íÊŸÈÓϵÄʯͷµÄÄÜÁ¿ÔœŽó¡£Ê¯Í·±ÈœÏŽó£¬Ôòœ«žÃµãËÄÖܵĵãÈ«²¿
; ÖÃΪ·Ç0Öµ¡£
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;
;
;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ifndef WAVEOBJ_INC
WAVEOBJ_INC equ 1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
F_WO_ACTIVE equ 0001h
F_WO_NEED_UPDATE equ 0002h
F_WO_EFFECT equ 0004h
F_WO_ELLIPSE equ 0008h
WAVE_OBJECT struct
hWnd dd ?
dwFlag dd ? ; Œû F_WO_xxx ×éºÏ
;********************************************************************
hDcRender dd ?
hBmpRender dd ?
lpDIBitsSource dd ? ; ÔÊŒÏñËØÊýŸÝ
lpDIBitsRender dd ? ; ÓÃÓÚÏÔÊŸµœÆÁÄ»µÄÏñËØÊýŸÝ
lpWave1 dd ? ; Ë®²šÄÜÁ¿ÊýŸÝ»º³å1
lpWave2 dd ? ; Ë®²šÄÜÁ¿ÊýŸÝ»º³å2
;********************************************************************
dwBmpWidth dd ?
dwBmpHeight dd ?
dwDIByteWidth dd ? ; = (dwBmpWidth * 3 + 3) and ~3
dwWaveByteWidth dd ? ; = dwBmpWidth * 4
dwRandom dd ?
;********************************************************************
; ÌØЧ²ÎÊý
;********************************************************************
dwEffectType dd ?
dwEffectParam1 dd ?
dwEffectParam2 dd ?
dwEffectParam3 dd ?
;********************************************************************
; ÓÃÓÚÐÐŽ¬ÌØЧ
;********************************************************************
dwEff2X dd ?
dwEff2Y dd ?
dwEff2XAdd dd ?
dwEff2YAdd dd ?
dwEff2Flip dd ?
;********************************************************************
stBmpInfo BITMAPINFO <>
WAVE_OBJECT ends
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Ëæ»úÊý²úÉú×Ó³ÌÐò
; ÊäÈ룺Ҫ²úÉúµÄËæ»úÊýµÄ×îŽóÖµ£¬Êä³ö£ºËæ»úÊý
; žùŸÝ£º
; 1. Êýѧ¹«Êœ Rnd=(Rnd*I+J) mod K Ñ»·»ØŽøÉú³É K ŽÎÒÔÄÚ²»ÖØžŽµÄ
; αËæ»úÊý£¬µ«K,I,J±ØÐëΪËØÊý
; 2. 2^(2n-1)-1 ±Ø¶šÎªËØÊý£šŒŽ2µÄÆæÊýŽÎ·œŒõ1£©
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveRandom16 proc _lpWaveObject
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
push edx
push ecx
mov eax,[ebx].dwRandom
mov ecx,32768-1 ;2^15-1
mul ecx
add eax,2048-1 ;2^11-1
adc edx,0
mov ecx,2147483647 ;2^31-1
div ecx
mov eax,[ebx].dwRandom
mov [ebx].dwRandom,edx
and eax,0000ffffh
pop ecx
pop edx
ret
_WaveRandom16 endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveRandom proc uses ebx ecx edx _lpWaveObject,_dwMax
invoke _WaveRandom16,_lpWaveObject
mov edx,eax
invoke _WaveRandom16,_lpWaveObject
shl eax,16
or ax,dx
mov ecx,_dwMax
or ecx,ecx
jz @F
xor edx,edx
div ecx
mov eax,edx
@@:
ret
_WaveRandom endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ²šÄÜÀ©É¢
; Ëã·š£º
; Wave2(x,y) = (Wave1(x+1,y)+Wave1(x-1,y)+Wave1(x,y+1)+Wave1(x,y-1))/2-Wave2(x,y)
; Wave2(x,y) = Wave2(x,y) - Wave2(x,y) >> 5
; xchg Wave1,Wave2
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveSpread proc _lpWaveObject
pushad
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
;********************************************************************
test [ebx].dwFlag,F_WO_ACTIVE
jz _Ret
mov esi,[ebx].lpWave1
mov edi,[ebx].lpWave2
mov ecx,[ebx].dwBmpWidth
mov eax,[ebx].dwBmpHeight
dec eax
mul ecx
;********************************************************************
; ebx = width
; ecx = i£¬eax = max
;********************************************************************
.while ecx < eax
push eax
.if [ebx].dwFlag & F_WO_ELLIPSE
mov edx,[esi+ecx*4-1*4]
add edx,[esi+ecx*4+1*4]
add edx,[esi+ecx*4-2*4]
add edx,[esi+ecx*4+2*4]
lea edx,[edx+edx*2]
add edx,[esi+ecx*4-3*4]
add edx,[esi+ecx*4-3*4]
add edx,[esi+ecx*4+3*4]
add edx,[esi+ecx*4+3*4]
lea eax,[esi+ecx*4]
sub eax,[ebx].dwWaveByteWidth
mov eax,[eax]
shl eax,3
add edx,eax
lea eax,[esi+ecx*4]
add eax,[ebx].dwWaveByteWidth
mov eax,[eax]
shl eax,3
add edx,eax
sar edx,4
sub edx,[edi+ecx*4]
mov eax,edx
sar eax,5
sub edx,eax
mov [edi+ecx*4],edx
.else
mov edx,[esi+ecx*4-1*4]
add edx,[esi+ecx*4+1*4]
lea eax,[esi+ecx*4]
sub eax,[ebx].dwWaveByteWidth
add edx,[eax]
lea eax,[esi+ecx*4]
add eax,[ebx].dwWaveByteWidth
add edx,[eax]
sar edx,1
sub edx,[edi+ecx*4]
mov eax,edx
sar eax,5
sub edx,eax
mov [edi+ecx*4],edx
.endif
pop eax
inc ecx
.endw
mov [ebx].lpWave1,edi
mov [ebx].lpWave2,esi
_Ret:
;********************************************************************
assume ebx:nothing
popad
ret
_WaveSpread endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; esi -> edi, ecx = line width
; return = (4*Pixel(x,y)+3*Pixel(x-1,y)+3*Pixel(x+1,y)+3*Pixel(x,y+1)+3*Pixel(x,y-1))/16
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveGetPixel:
movzx eax,byte ptr [esi]
shl eax,2
movzx edx,byte ptr [esi+3]
lea edx,[edx+2*edx]
add eax,edx
movzx edx,byte ptr [esi-3]
lea edx,[edx+2*edx]
add eax,edx
movzx edx,byte ptr [esi+ecx]
lea edx,[edx+2*edx]
add eax,edx
mov edx,esi
sub edx,ecx
movzx edx,byte ptr [edx]
lea edx,[edx+2*edx]
add eax,edx
shr eax,4
mov [edi],al
inc esi
inc edi
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; äÖÈŸ×Ó³ÌÐò£¬œ«ÐµÄÖ¡ÊýŸÝäÖÈŸµœ lpDIBitsRender ÖÐ
; Ëã·š£º
; posx = Wave1(x-1,y)-Wave1(x+1,y)+x
; posy = Wave1(x,y-1)-Wave1(x,y+1)+y
; SourceBmp(x,y) = DestBmp(posx,posy)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveRender proc _lpWaveObject
local @dwPosX,@dwPosY,@dwPtrSource,@dwFlag
pushad
xor eax,eax
mov @dwFlag,eax
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
test [ebx].dwFlag,F_WO_ACTIVE
jz _Ret
or [ebx].dwFlag,F_WO_NEED_UPDATE
mov esi,[ebx].lpWave1
mov edi,[ebx].dwWaveByteWidth ; edi = ÏñËØÖžÕë
xor ecx,ecx
inc ecx ; ecx=i -- i=1; i<height; i++
_Loop1:
xor edx,edx ; edx=j -- j=0; j<width; j++
_Loop2:
push edx
;********************************************************************
; PosY=i+ÏñËØÉÏ1ÄÜÁ¿-ÏñËØÏÂ1ÄÜÁ¿
; PosX=j+ÏñËØ×ó1ÄÜÁ¿-ÏñËØÓÒ1ÄÜÁ¿
;********************************************************************
mov eax,edi
sub eax,[ebx].dwWaveByteWidth
mov eax,[esi+eax]
mov @dwPosY,eax
mov eax,[ebx].dwWaveByteWidth
lea eax,[edi+eax]
mov eax,[esi+eax]
sub @dwPosY,eax
add @dwPosY,ecx
mov eax,[esi+edi-4]
sub eax,[esi+edi+4]
add eax,edx ;@dwPosX = eax
mov @dwPosX,eax
cmp eax,0
jl _Continue
cmp eax,[ebx].dwBmpWidth
jge _Continue
mov eax,@dwPosY
cmp eax,0
jl _Continue
cmp eax,[ebx].dwBmpHeight
jge _Continue
;********************************************************************
; ptrSource = dwPosY * dwDIByteWidth + dwPosX * 3
; ptrDest = i * dwDIByteWidth + j * 3
;********************************************************************
mov eax,@dwPosX
lea eax,[eax+eax*2]
mov @dwPosX,eax
push edx
mov eax,@dwPosY
mul [ebx].dwDIByteWidth
add eax,@dwPosX
mov @dwPtrSource,eax
mov eax,ecx
mul [ebx].dwDIByteWidth
pop edx
lea edx,[edx+edx*2]
add eax,edx ;@dwPtrDest = eax
;********************************************************************
; äÖÈŸÏñËØ [ptrDest] = ÔÊŒÏñËØ [ptrSource]
;********************************************************************
pushad
mov ecx,@dwPtrSource
mov esi,[ebx].lpDIBitsSource
mov edi,[ebx].lpDIBitsRender
lea esi,[esi+ecx]
lea edi,[edi+eax]
.if ecx != eax
or @dwFlag,1 ;Èç¹ûŽæÔÚÔŽÏñËغÍÄ¿±êÏñËز»Í¬£¬Ôò±íÊŸ»¹Ôڻ׎̬
mov ecx,[ebx].dwDIByteWidth
call _WaveGetPixel
call _WaveGetPixel
call _WaveGetPixel
.else
cld
movsw
movsb
.endif
popad
;********************************************************************
; ŒÌÐøÑ»·
;********************************************************************
_Continue:
pop edx
inc edx
add edi,4 ; ÏñËØ++
cmp edx,[ebx].dwBmpWidth
jb _Loop2
inc ecx
mov eax,[ebx].dwBmpHeight
dec eax
cmp ecx,eax
jb _Loop1
;********************************************************************
; œ«äÖÈŸµÄÏñËØÊýŸÝ¿œ±Žµœ hDc ÖÐ
;********************************************************************
invoke SetDIBits,[ebx].hDcRender,[ebx].hBmpRender,0,[ebx].dwBmpHeight,\
[ebx].lpDIBitsRender,addr [ebx].stBmpInfo,DIB_RGB_COLORS
.if ! @dwFlag
and [ebx].dwFlag,not F_WO_ACTIVE
.endif
_Ret:
;********************************************************************
assume ebx:nothing
popad
ret
_WaveRender endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveUpdateFrame proc _lpWaveObject,_hDc,_bIfForce
pushad
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
cmp _bIfForce,0
jnz @F
.if [ebx].dwFlag & F_WO_NEED_UPDATE
@@:
invoke BitBlt,_hDc,0,0,[ebx].dwBmpWidth,[ebx].dwBmpHeight,\
[ebx].hDcRender,0,0,SRCCOPY
and [ebx].dwFlag,not F_WO_NEED_UPDATE
.endif
assume ebx:nothing
popad
ret
_WaveUpdateFrame endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ÈÓÒ»¿éʯͷ
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveDropStone proc _lpWaveObject,_dwX,_dwY,_dwSize,_dwWeight
local @dwMaxX,@dwMaxY
pushad
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
;********************************************************************
; ŒÆË㷶Χ
;********************************************************************
mov edx,_dwSize
shr edx,1
mov eax,_dwX
mov esi,_dwY
mov ecx,eax
mov edi,esi
add eax,edx ; x + size
sub ecx,edx ; x - size
push edx
.if [ebx].dwFlag & F_WO_ELLIPSE
shr edx,1
.endif
add esi,edx ; y + size
sub edi,edx ; y - size
pop edx
shl edx,1
.if ! edx
inc edx
.endif
mov _dwSize,edx
;********************************************************************
; ÅжϷ¶Î§µÄºÏ·šÐÔ
;********************************************************************
inc eax
cmp eax,[ebx].dwBmpWidth
jge _Ret
cmp ecx,1
jl _Ret
inc esi
cmp esi,[ebx].dwBmpHeight
jge _Ret
cmp edi,1
jl _Ret
dec eax
dec esi
;********************************************************************
; œ«·¶Î§ÄڵĵãµÄÄÜÁ¿ÖÃΪ _dwWeight
;********************************************************************
mov @dwMaxX,eax
mov @dwMaxY,esi
.while ecx <= @dwMaxX
push edi
.while edi <= @dwMaxY
mov eax,ecx
sub eax,_dwX
imul eax
push eax
mov eax,edi
sub eax,_dwY
imul eax
pop edx
add eax,edx
push eax
mov eax,_dwSize
imul eax
pop edx
.if edx <= eax
mov eax,edi
mul [ebx].dwBmpWidth
add eax,ecx
shl eax,2
add eax,[ebx].lpWave1
push _dwWeight
pop [eax]
.endif
inc edi
.endw
pop edi
inc ecx
.endw
or [ebx].dwFlag,F_WO_ACTIVE
;********************************************************************
_Ret:
assume ebx:nothing
popad
ret
_WaveDropStone endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ŒÆËãÀ©É¢ÊýŸÝ¡¢äÖȟλ͌¡¢žüÐÂŽ°¿Ú¡¢ŽŠÀíÌØЧµÄ¶šÊ±Æ÷¹ý³Ì
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveTimerProc proc _hWnd,_uMsg,_idEvent,_dwTime
pushad
mov ebx,_idEvent
assume ebx:ptr WAVE_OBJECT
invoke _WaveSpread,ebx
invoke _WaveRender,ebx
.if [ebx].dwFlag & F_WO_NEED_UPDATE
invoke GetDC,[ebx].hWnd
invoke _WaveUpdateFrame,ebx,eax,FALSE
invoke ReleaseDC,[ebx].hWnd,eax
.endif
;********************************************************************
; ÌØЧŽŠÀí
;********************************************************************
test [ebx].dwFlag,F_WO_EFFECT
jz _Ret
mov eax,[ebx].dwEffectType
;********************************************************************
; Type = 1 Óêµã£¬Param1£œËٶȣš0×î¿ì£¬ÔœŽóÔœÂý£©£¬Param2£œÓêµãŽóС£¬Param3£œÄÜÁ¿
;********************************************************************
.if eax == 1
mov eax,[ebx].dwEffectParam1
or eax,eax
jz @F
invoke _WaveRandom,ebx,eax
.if ! eax
@@:
mov eax,[ebx].dwBmpWidth
dec eax
dec eax
invoke _WaveRandom,ebx,eax
inc eax
mov ecx,eax
mov eax,[ebx].dwBmpHeight
dec eax
dec eax
invoke _WaveRandom,ebx,eax
inc eax
mov edx,eax
invoke _WaveRandom,ebx,[ebx].dwEffectParam2
inc eax
mov esi,eax
invoke _WaveRandom,ebx,[ebx].dwEffectParam3
add eax,50
invoke _WaveDropStone,ebx,ecx,edx,esi,eax
.endif
;********************************************************************
; Type = 2 ÐÐŽ¬£¬Param1£œËٶȣš0×î¿ì£¬ÔœŽóÔœ¿ì£©£¬Param2£œŽóС£¬Param3£œÄÜÁ¿
;********************************************************************
.elseif eax == 2
inc [ebx].dwEff2Flip
test [ebx].dwEff2Flip,1
jnz _Ret
mov ecx,[ebx].dwEff2X
mov edx,[ebx].dwEff2Y
add ecx,[ebx].dwEff2XAdd
add edx,[ebx].dwEff2YAdd
cmp ecx,1
jge @F
sub ecx,1
neg ecx
neg [ebx].dwEff2XAdd
@@:
cmp edx,1
jge @F
sub edx,1
neg edx
neg [ebx].dwEff2YAdd
@@:
mov eax,[ebx].dwBmpWidth
dec eax
cmp ecx,eax
jl @F
sub ecx,eax
xchg eax,ecx
sub ecx,eax
neg [ebx].dwEff2XAdd
@@:
mov eax,[ebx].dwBmpHeight
dec eax
cmp edx,eax
jl @F
sub edx,eax
xchg eax,edx
sub edx,eax
neg [ebx].dwEff2YAdd
@@:
mov [ebx].dwEff2X,ecx
mov [ebx].dwEff2Y,edx
invoke _WaveDropStone,ebx,ecx,edx,[ebx].dwEffectParam2,[ebx].dwEffectParam3
;********************************************************************
; Type = 3 ²šÀË£¬Param1£œÃܶȣ¬Param2£œŽóС£¬Param3£œÄÜÁ¿
;********************************************************************
.elseif eax == 3
xor edi,edi
.while edi <= [ebx].dwEffectParam1
mov eax,[ebx].dwBmpWidth
dec eax
dec eax
invoke _WaveRandom,ebx,eax
inc eax
mov ecx,eax
mov eax,[ebx].dwBmpHeight
dec eax
dec eax
invoke _WaveRandom,ebx,eax
inc eax
mov edx,eax
invoke _WaveRandom,ebx,[ebx].dwEffectParam2
inc eax
mov esi,eax
invoke _WaveRandom,ebx,[ebx].dwEffectParam3
invoke _WaveDropStone,ebx,ecx,edx,esi,eax
inc edi
.endw
.endif
_Ret:
assume ebx:nothing
popad
ret
_WaveTimerProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ÊͷŶÔÏó
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveFree proc _lpWaveObject
pushad
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
;********************************************************************
.if [ebx].hDcRender
invoke DeleteDC,[ebx].hDcRender
.endif
.if [ebx].hBmpRender
invoke DeleteObject,[ebx].hBmpRender
.endif
.if [ebx].lpDIBitsSource
invoke GlobalFree,[ebx].lpDIBitsSource
.endif
.if [ebx].lpDIBitsRender
invoke GlobalFree,[ebx].lpDIBitsRender
.endif
.if [ebx].lpWave1
invoke GlobalFree,[ebx].lpWave1
.endif
.if [ebx].lpWave2
invoke GlobalFree,[ebx].lpWave2
.endif
invoke KillTimer,[ebx].hWnd,ebx
invoke RtlZeroMemory,ebx,sizeof WAVE_OBJECT
;********************************************************************
assume ebx:nothing
popad
ret
_WaveFree endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ³õÊŒ»¯¶ÔÏó
; ²ÎÊý£º_lpWaveObject £œ ÖžÏò WAVE_OBJECTµÄÖžÕë
; ·µ»Ø£ºeax = 0 ³É¹Š¡¢= 1 ʧ°Ü
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveInit proc _lpWaveObject,_hWnd,_hBmp,_dwSpeed,_dwType
local @stBmp:BITMAP,@dwReturn
pushad
xor eax,eax
mov @dwReturn,eax
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
invoke RtlZeroMemory,ebx,sizeof WAVE_OBJECT
.if _dwType
or [ebx].dwFlag,F_WO_ELLIPSE
.endif
;********************************************************************
; »ñȡλ͌³ßŽç
;********************************************************************
push _hWnd
pop [ebx].hWnd
invoke GetTickCount
mov [ebx].dwRandom,eax
invoke GetObject,_hBmp,sizeof BITMAP,addr @stBmp
.if ! eax
@@:
inc @dwReturn
jmp _Ret
.endif
mov eax,@stBmp.bmHeight
mov [ebx].dwBmpHeight,eax
cmp eax,3
jle @B
mov eax,@stBmp.bmWidth
mov [ebx].dwBmpWidth,eax
cmp eax,3
jle @B
push eax
shl eax,2
mov [ebx].dwWaveByteWidth,eax
pop eax
lea eax,[eax+eax*2]
add eax,3
and eax,not 0011b
mov [ebx].dwDIByteWidth,eax
;********************************************************************
; ŽŽœšÓÃÓÚäÖÈŸµÄλ͌
;********************************************************************
invoke GetDC,_hWnd
mov esi,eax
invoke CreateCompatibleDC,esi
mov [ebx].hDcRender,eax
invoke CreateCompatibleBitmap,esi,[ebx].dwBmpWidth,[ebx].dwBmpHeight
mov [ebx].hBmpRender,eax
invoke SelectObject,[ebx].hDcRender,eax
;********************************************************************
; ·ÖÅ䲚ÄÜ»º³åÇø
;********************************************************************
mov eax,[ebx].dwWaveByteWidth
mul [ebx].dwBmpHeight
mov edi,eax
invoke GlobalAlloc,GPTR,edi
mov [ebx].lpWave1,eax
invoke GlobalAlloc,GPTR,edi
mov [ebx].lpWave2,eax
;********************************************************************
; ·ÖÅäÏñËØ»º³åÇø
;********************************************************************
mov eax,[ebx].dwDIByteWidth
mul [ebx].dwBmpHeight
mov edi,eax
invoke GlobalAlloc,GPTR,edi
mov [ebx].lpDIBitsSource,eax
invoke GlobalAlloc,GPTR,edi
mov [ebx].lpDIBitsRender,eax
;********************************************************************
; »ñÈ¡ÔÊŒÏñËØÊýŸÝ
;********************************************************************
mov [ebx].stBmpInfo.bmiHeader.biSize,sizeof BITMAPINFOHEADER
push [ebx].dwBmpWidth
pop [ebx].stBmpInfo.bmiHeader.biWidth
mov eax,[ebx].dwBmpHeight
neg eax
mov [ebx].stBmpInfo.bmiHeader.biHeight,eax
inc [ebx].stBmpInfo.bmiHeader.biPlanes
mov [ebx].stBmpInfo.bmiHeader.biBitCount,24
mov [ebx].stBmpInfo.bmiHeader.biCompression,BI_RGB
mov [ebx].stBmpInfo.bmiHeader.biSizeImage,0
invoke CreateCompatibleDC,esi
push eax
invoke SelectObject,eax,_hBmp
invoke ReleaseDC,_hWnd,esi
pop eax
mov esi,eax
invoke GetDIBits,esi,_hBmp,0,[ebx].dwBmpHeight,[ebx].lpDIBitsSource,\
addr [ebx].stBmpInfo,DIB_RGB_COLORS
invoke GetDIBits,esi,_hBmp,0,[ebx].dwBmpHeight,[ebx].lpDIBitsRender,\
addr [ebx].stBmpInfo,DIB_RGB_COLORS
invoke DeleteDC,esi
.if ![ebx].lpWave1 || ![ebx].lpWave2 || ![ebx].lpDIBitsSource ||\
![ebx].lpDIBitsRender || ![ebx].hDcRender
invoke _WaveFree,ebx
inc @dwReturn
.endif
invoke SetTimer,_hWnd,ebx,_dwSpeed,addr _WaveTimerProc
or [ebx].dwFlag,F_WO_ACTIVE or F_WO_NEED_UPDATE
invoke _WaveRender,ebx
invoke GetDC,[ebx].hWnd
invoke _WaveUpdateFrame,ebx,eax,TRUE
invoke ReleaseDC,[ebx].hWnd,eax
;********************************************************************
_Ret:
assume ebx:nothing
popad
mov eax,@dwReturn
ret
_WaveInit endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; һЩÌØЧ
; ÊäÈ룺_dwType = 0 ¹Ø±ÕÌØЧ
; _dwType <> 0 ¿ªÆôÌØЧ£¬²ÎÊýŸßÌåŒûÉÏÃæ
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WaveEffect proc uses ebx eax _lpWaveObject,\
_dwType,_dwParam1,_dwParam2,_dwParam3
local @dwMaxX,@dwMaxY
mov ebx,_lpWaveObject
assume ebx:ptr WAVE_OBJECT
;********************************************************************
mov eax,_dwType
.if eax == 0
;********************************************************************
; ¹Ø±ÕÌØЧ
;********************************************************************
and [ebx].dwFlag,not F_WO_EFFECT
mov [ebx].dwEffectType,eax
.elseif eax == 2
;********************************************************************
; ÐÐŽ¬ÌØЧ
;********************************************************************
mov eax,_dwParam1
mov [ebx].dwEff2XAdd,eax
mov [ebx].dwEff2YAdd,eax
mov eax,[ebx].dwBmpWidth
dec eax
dec eax
invoke _WaveRandom,ebx,eax
inc eax
mov [ebx].dwEff2X,eax
mov eax,[ebx].dwBmpHeight
dec eax
dec eax
invoke _WaveRandom,ebx,eax
inc eax
mov [ebx].dwEff2Y,eax
jmp @F
.else
;********************************************************************
; ĬÈÏ
;********************************************************************
@@:
push _dwType
pop [ebx].dwEffectType
push _dwParam1
pop [ebx].dwEffectParam1
push _dwParam2
pop [ebx].dwEffectParam2
push _dwParam3
pop [ebx].dwEffectParam3
or [ebx].dwFlag,F_WO_EFFECT
.endif
;********************************************************************
assume ebx:nothing
ret
_WaveEffect endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;
;
;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
endif
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |