FASM DirectDraw Test

Source: Internet
Author: User

Take the first three header files and write a simple test:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>; * -- = -- * FASM DirectDraw test .; * -- = -- * by G-spider; * -- = -- * FASM ddraw. ASM ddraw.exe; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> format pe gui 4.0 entry startinclude 'win32. INC 'include 'ddraw. INC 'macro retjnz labal {test eax, eax jnz labal} macro retjz labal {test eax, eax JZ labal} my_ddrawerr = (wm_user + 1 );--------------- --------------------------------------------- Section '. text 'Code readable writeable executable start: invoke getmodulehandle, 0 mov [WC. hinstance], eax invoke loadcursor, 0, idc_arrow mov [WC. hcursor], eax invoke registerclass, WC retjz end_loop invoke getsystemmetrics, sm_cxscreen mov [point. x], eax SHR eax, 1 mov [txtpoint. x], eax invoke getsystemmetrics, sm_cyscreen mov [point. y], eax SHR eax, 1 mov [txtpo Int. y], eax invoke create‑wex, 0, szclass, sztitle, ws_popup, 0, 0, [point. x], [point. y], null, null, [WC. hinstance], null retjz end_loop mov [hwnd], eax; ========================================================== =; create the directcraw object invoke directdrawcreate, null, ddraw, null retjnz end_loop; obtain the exclusive and full screen mode cominvk ddraw, writable, [hwnd], writable + javasretjnz ddraw_err; initialize the callback structure invoke RT Mory, ddsd, sizeof. ddsurfacedesc mov [ddsd. dwsize], sizeof. ddsurfacedesc; get the current display mode cominvk ddraw, getdisplaymode, ddsd retjnz ddraw_err; set the display mode cominvk ddraw, setdisplaymode, [ddsd. dwwidth], [ddsd. dwheight], [ddsd. ddpfpixelformat. dwrgbbitcount] retjnz ddraw_err; fill in the homepage information mov [ddsd. dwflags], ddsd_caps mov [ddsd. ddscaps. dwcaps], ddscaps_primarysurface cominvk ddraw, createsurface, ddsd, ddsprimary, null retjnz Ddraw_err; create the device environment handle on this page. The device environment is compatible with GDI, cominvk ddsprimary, getdc, HDC retjnz ddraw_err; output text invoke setbkcolor, [HDC], 0x000000ff invoke settextcolor, [HDC], 0x00ffff00 invoke textout, [HDC], [txtpoint. x], [txtpoint. y], stmsg, dwlenmsg invoke showwindow, [hwnd], sw_shownormal invoke updatewindow, [hwnd]; ========================================================== = msg_loop: invoke getmessage, MSG, null, 0, 0 retjz end_loop invoke Translatemessage, MSG invoke dispatchmessage, msg jmp msg_loop end_loop: invoke exitprocess, [MSG. wparam] ddraw_err: invoke wsprintf, buff, szerrmsg, eax invoke sendmessage, [hwnd], my_ddrawerr, buff, szerrtitle JMP msg_loop; ========================================================== ====================================== proc windowproc uses ebx esi edi, hwnd, umsg, wparam, lparam CMP [umsg], wm_destroy je. wmdestroy CMP [umsg], my_ddrawerr je. Myddrawerr CMP [umsg], wm_keydown je. wmkeydown CMP [umsg], wm_paint je. wnpaint. defwndproc: invoke defwindowproc, [hwnd], [umsg], [wparam], [lparam] JMP. finish. myddrawerr: invoke MessageBox, [hwnd], [wparam], [lparam], mb_ OK + mb_iconerror invoke destroywindow, [hwnd] invoke postquitmessage, 1 JMP. finish. wmkeydown: mov eax, [wparam] CMP eax, vk_escape JNE. defwndproc invoke postquitmessage, 1 JMP. finish. Wnpaint: invoke textout, [HDC], [txtpoint. x], [txtpoint. y], stmsg, dwlenmsg JMP. finish. wmdestroy:; cominvk ddraw, restoredisplaymode cominvk ddsprimary, releasedc, [HDC] cominvk ddraw, release invoke postquitmessage, 0 XOR eax, eax. finish: retendp; ------------------------------------------------------------ section '. BSS 'readable writeable hinstance handle hwnd handle HDC handle MSG point txtpoi NT point ddsd ddsurfacedesc ddraw DirectDraw ddsprimary directdrawsurface buff tchar 256 DUP (?); -------------------------------------------------------------- Section '. data 'data readable writeable sztitle tchar 'flat extends er DirectDraw application', 0 szclass tchar 'fddraw32', 0; define_guid <strong, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0 x, 0x60, 0 x, 0x97, 0xea, 0x5b> WC wndclass 0, windowproc, null, color_window + 1, null, szclass szerrtitle tchar 'error', 0 szpause tchar 'pause', 0 szfmt0 tchar 'msgindex = % x', 0ah, '% d * % d % DHZ ', 0 szerrmsg tchar 'ddraw _ err_code = 0x % x', 0ah, 0 stmsg tchar 'G-spider @ 2013 'dwlenmsg = ($-stmsg)/sizeof. tchar; ------------------------------------------------------------ section '. idata 'import data readable writeable library Kernel32, 'kernel32. dll ', \ USER32, 'user32. dll ', \ ddraw, 'ddraw. dll ', \ GDI32, 'gdi32. DLL 'include 'API \ kernel32.inc 'include' API \ user32.inc 'include 'API \ gdi32.inc 'import ddraw, \ directdrawcreate, 'directdrawcreate'

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.