?? ripper.asm
字號:
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 水波特效演示程序
; by 羅云彬,http://asm.yeah.net,luoyunbin@sina.com
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 所有實現特效的代碼單獨封裝在 WaveObject.asm 中
; 具體使用方法見 WaveObject.asm 中的說明
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat, stdcall
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定義
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
include Gdi32.inc
includelib Gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 數據段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 數據段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.const
szClassName db 'Ripper',0
szTitle db '水波效果 - http://asm.yeah.net',0
szTip db '水波特效演示 by 羅云彬',0dh,0ah
db '使用Win32匯編語言編寫,源代碼見http://asm.yeah.net',0dh,0ah,0dh,0ah
db '鼠標左鍵:在點擊處激發水波',0dh,0ah
db '鼠標右鍵:循環切換特效(下雨、快艇、波浪等)',0
szError db '初始化水波對象錯誤!',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代碼段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include WaveObject.asm
.data?
stWaveObj WAVE_OBJECT <?>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Quit proc
invoke _WaveFree,addr stWaveObj
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
ret
_Quit endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Init proc
local @stBmp:BITMAP
;********************************************************************
; 裝入資源中的位圖、初始化水波對象
;********************************************************************
invoke LoadBitmap,hInstance,1
push eax
invoke _WaveInit,addr stWaveObj,hWinMain,eax,30,0
.if eax
invoke MessageBox,hWinMain,addr szError,addr szTitle,MB_OK or MB_ICONSTOP
invoke _Quit
.else
invoke MessageBox,hWinMain,addr szTip,addr szTitle,MB_OK
.endif
pop eax
invoke DeleteObject,eax
;********************************************************************
; 將窗口大小修正到位圖的大小
;********************************************************************
mov eax,stWaveObj.dwBmpWidth
mov ecx,stWaveObj.dwBmpHeight
add eax,6
add ecx,25
invoke SetWindowPos,hWinMain,HWND_TOPMOST,0,0,eax,ecx,\
SWP_NOMOVE
invoke _WaveEffect,addr stWaveObj,1,5,4,250
ret
_Init endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
local @stPs:PAINTSTRUCT,@hDc,@stRect:RECT
mov eax,uMsg
;********************************************************************
.if eax == WM_CREATE
push hWnd
pop hWinMain
call _Init
.elseif eax == WM_CLOSE
call _Quit
.elseif eax == WM_PAINT
invoke BeginPaint,hWnd,addr @stPs
mov @hDc,eax
invoke _WaveUpdateFrame,addr stWaveObj,eax,TRUE
invoke EndPaint,hWnd,addr @stPs
xor eax,eax
ret
;********************************************************************
; 鼠標左鍵激起水波
;********************************************************************
.elseif eax == WM_LBUTTONDOWN
mov eax,lParam
movzx ecx,ax ; x
shr eax,16 ; y
invoke _WaveDropStone,addr stWaveObj,ecx,eax,2,256
;********************************************************************
; 鼠標右鍵切換特效
;********************************************************************
.elseif eax == WM_RBUTTONDOWN
mov eax,stWaveObj.dwEffectType
.if eax == 0
invoke _WaveEffect,addr stWaveObj,1,5,4,250
.elseif eax == 1
invoke _WaveEffect,addr stWaveObj,3,250,4,8
.elseif eax == 3
invoke _WaveEffect,addr stWaveObj,2,4,2,180
.else
invoke _WaveEffect,addr stWaveObj,0,0,0,0
.endif
;********************************************************************
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
;********************************************************************
xor eax,eax
ret
_ProcWinMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG
invoke GetModuleHandle,NULL
mov hInstance,eax
;********************************************************************
; 注冊窗口類
;********************************************************************
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
invoke LoadCursor,0,IDC_ARROW
mov @stWndClass.hCursor,eax
push hInstance
pop @stWndClass.hInstance
mov @stWndClass.cbSize,sizeof WNDCLASSEX
mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
mov @stWndClass.lpfnWndProc,offset _ProcWinMain
mov @stWndClass.hbrBackground,COLOR_WINDOW + 1
mov @stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr @stWndClass
;********************************************************************
; 建立并顯示窗口
;********************************************************************
invoke CreateWindowEx,NULL,\
offset szClassName,offset szTitle,\
WS_OVERLAPPED or WS_SYSMENU,\
300,300,500,500,\
NULL,NULL,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
;********************************************************************
; 消息循環
;********************************************************************
.while TRUE
invoke GetMessage,addr @stMsg,NULL,0,0
.break .if eax == 0
invoke TranslateMessage,addr @stMsg
invoke DispatchMessage,addr @stMsg
.endw
ret
_WinMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
call _WinMain
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -