satpro

DirectX 9Ex Borderless Window

Feb 16th, 2026 (edited)
17,794
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASM (NASM) 4.38 KB | Source Code | 0 0
  1.  
  2.  
  3.  
  4. ; ========================================================================================
  5.  
  6. align 16
  7. export D3D9_Startup:
  8.  
  9.   sub rsp, 48h
  10.  
  11. ; ----- ENTER -----
  12.  
  13.  
  14. ; ----------------------------
  15. ;   zero the interface ptrs
  16. ; ----------------------------
  17.   xor eax, eax
  18.   mov [pp_D3D], rax
  19.   mov [pp_Device], rax
  20.   mov [pp_Texture], rax
  21.  
  22. ; -----------------------------------------------------------------
  23. ; HRESULT  Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9EX **ppD3D)
  24. ; -----------------------------------------------------------------
  25.   mov ecx, D3D_SDK_VERSION              ; p1: UINT SDKVersion
  26.   lea rdx, pp_D3D                       ; p2: IDirect3D9EX **ppD3D
  27.   call Direct3DCreate9Ex
  28.     test eax, eax
  29.     jnz >> .d3d9LError
  30.  
  31. ; --------------------------------------
  32. ; zero D3DPRESENT_PARAMETERS structure
  33. ; --------------------------------------
  34.   lea edx, d3dpp
  35.   xor eax, eax                          ; fillvalue = 0
  36.   mov ecx, sizeof(D3DPRESENT_PARAMETERS / 8) ; size /8 bytes per fill
  37.  
  38. : mov [edx], rax
  39.   add edx, 8
  40.   dec ecx
  41.   jnz <
  42.  
  43. ; --------------------------------------
  44. ; fill D3DPRESENT_PARAMETERS structure
  45. ; --------------------------------------
  46.   mov D[d3dpp.BackBufferWidth], SCREENWIDTH       ; 1920
  47.   mov D[d3dpp.BackBufferHeight], SCREENHEIGHT     ; 1080
  48.   mov D[d3dpp.BackBufferFormat], D3DFMT_X8R8G8B8  ; 22
  49.   mov D[d3dpp.BackBufferCount], 1
  50.   mov D[d3dpp.SwapEffect], D3DSWAPEFFECT_FLIPEX   ; 5
  51.   mov rax, [hWindow]
  52.   mov [d3dpp.hDeviceWindow], rax
  53.   mov D[d3dpp.Windowed], TRUE
  54.   mov D[d3dpp.PresentationInterval], D3DPRESENT_INTERVAL_IMMEDIATE
  55.  
  56. ; ------------------
  57. ; create the device
  58. ; ------------------
  59. ; HRESULT CreateDeviceEx(
  60.   mov rcx, [pp_D3D]           ; p1: *this
  61.   xor edx, edx                ; p2: UINT Adapter = 0
  62.   mov r8d, D3DDEVTYPE_HAL     ; p3: D3DDEVTYPE DeviceType (1)
  63.   mov r9, [hWindow]      ; p4: HWND hFocusWindow
  64.   mov D[rsp+20h], D3DCREATE_HARDWARE_VERTEXPROCESSING ; p5: DWORD BehaviorFlags (40h)
  65.   lea rax, d3dpp
  66.   mov [rsp+28h], rax          ; p6: D3DPRESENT_PARAMETERS *pPresentationParameters
  67.   xor eax, eax
  68.   mov [rsp+30h], rax          ; p7: D3DDISPLAYMODEEX *pFullscreenDisplayMode
  69.   lea rax, pp_Device
  70.   mov [rsp+38h], rax          ; p8: IDirect3DDevice9Ex **ppReturnedDeviceInterface
  71.  
  72.   mov rax, [rcx]
  73.   add rax, IDirect3D9Ex_CreateDeviceEx
  74.   call [rax]
  75.     test eax, eax
  76.     jnz >> .d3d9LError
  77.  
  78. ; ------------------
  79. ; create the texture
  80. ; ------------------
  81.  
  82. ; HRESULT CreateTexture
  83.   mov rcx, [pp_Device]                  ; p1: *this
  84.   mov edx, 1920                         ; p2: UINT Width
  85.   mov r8d, 1080                         ; p3: UINT Height
  86.   mov r9d, 1                            ; p4: UINT Levels
  87.   mov D[rsp+20h], D3DUSAGE_DYNAMIC      ; p5: DWORD Usage
  88.   mov D[rsp+28h], D3DFMT_X8R8G8B8       ; p6: D3DFORMAT Format
  89.   mov D[rsp+30h], D3DPOOL_DEFAULT       ; p7: D3DPOOL Pool
  90.   lea rax, pp_Texture
  91.   mov [rsp+38h], rax                    ; p8: IDirect3DTexture9 **ppTexture
  92.   xor eax, eax
  93.   mov [rsp+40h], rax                    ; p9: HANDLE *pSharedHandle
  94.  
  95.   mov rax, [rcx]
  96.   add rax, IDirect3DDevice9Ex_CreateTexture
  97.   call [rax]
  98.     test eax, eax
  99.     jnz >> .d3d9LError
  100.  
  101.  
  102. ; ----- EXIT -----
  103.  
  104.   mov eax, TRUE               ; return 1 if successful
  105.   jmp > .d3d9LExit
  106.  
  107. .d3d9LError:
  108.   xor rax, rax               ; return 0 if error
  109.  
  110. .d3d9LExit:
  111.   add rsp, 48h
  112.   ret
  113.  
  114. ; ========================================================================================
  115.  
  116. align 16
  117. export D3D9_Shutdown:
  118.  
  119.   sub rsp, 28h
  120.  
  121. ; ----- Enter -----
  122.  
  123.   mov eax, [pp_D3D]
  124.   or eax, eax
  125.   jz >> .d3d9uExit
  126.  
  127. ; release back buffer interface
  128.   mov rcx, [pp_Texture]
  129.   mov rax, [rcx]
  130.   add eax, IDirect3DTexture9_Release
  131.   call [rax]
  132.     or eax, eax
  133.     jnz >> .d3d9uExit
  134.  
  135. ; release front buffer interface
  136.   mov rcx, [pp_Device]
  137.   mov rax, [rcx]
  138.   add eax, IDirect3DDevice9Ex_Release
  139.   call [rax]
  140.     or eax, eax
  141.     jnz >> .d3d9uExit
  142.  
  143. ; release DirectDraw 7 interface
  144.   mov rcx, [pp_D3D]
  145.   mov rax, [rcx]
  146.   add eax, IDirect3D9Ex_Release
  147.   call [rax]
  148.     or eax, eax
  149.     jnz >> .d3d9uExit
  150.  
  151. ; zero the DDraw interface ptrs
  152.   xor eax, eax
  153.   mov [pp_Texture], rax
  154.   mov [pp_Device], rax
  155.   mov [pp_D3D], rax
  156.  
  157.  
  158. ; -----  Exit  -----
  159.  
  160. .d3d9uExit:
  161.   add rsp, 28h
  162.   ret
  163.  
  164. ; ========================================================================================
  165.  
  166.  
Advertisement