diff --git a/build/graphics/poker.exe b/build/graphics/poker.exe index a19b5f5..a6e03f8 100644 Binary files a/build/graphics/poker.exe and b/build/graphics/poker.exe differ diff --git a/casino3d.inc b/casino3d.inc index ec7871a..6b02338 100644 --- a/casino3d.inc +++ b/casino3d.inc @@ -41,6 +41,10 @@ WaitForSingleObject PROTO :DWORD,:DWORD timeBeginPeriod PROTO :DWORD timeEndPeriod PROTO :DWORD timeGetTime PROTO +GetCursorPos PROTO :DWORD +SetCursorPos PROTO :DWORD,:DWORD +ShowCursor PROTO :DWORD +ClientToScreen PROTO :DWORD,:DWORD C3D_POINT STRUCT x dd ? @@ -178,6 +182,9 @@ hRaycastDoneEvent dd 0 bRaycastQuit dd 0 raycastThreadId dd 0 +ALIGN 4 +mouseLocked3D dd 0 + bmi3D C3D_BITMAPINFO <> msg3D C3D_MSG <> wc3D C3D_WNDCLASSEX <> @@ -4389,10 +4396,95 @@ skill_render_keys: ret RenderSkillGame ENDP +; --- Mouse Lock & Unlock Routines for Free Camera Look --- +LockMouse3D PROC + LOCAL rcClient[16]:BYTE + LOCAL ptCenter:C3D_POINT + cmp mouseLocked3D, 1 + je lock_done + mov mouseLocked3D, 1 + invoke ShowCursor, 0 + lea eax, rcClient + invoke GetClientRect, h3DWnd, eax + mov eax, dword ptr rcClient[8] + shr eax, 1 + mov ptCenter.x, eax + mov eax, dword ptr rcClient[12] + shr eax, 1 + mov ptCenter.y, eax + lea eax, ptCenter + invoke ClientToScreen, h3DWnd, eax + invoke SetCursorPos, ptCenter.x, ptCenter.y +lock_done: + ret +LockMouse3D ENDP + +UnlockMouse3D PROC + cmp mouseLocked3D, 0 + je unlock_done + mov mouseLocked3D, 0 + invoke ShowCursor, 1 +unlock_done: + ret +UnlockMouse3D ENDP + +UpdateMouseLockState PROC + cmp engineMode, MODE_WALK + jne unlock_it + cmp paused3D, 0 + jne unlock_it + invoke GetForegroundWindow + cmp eax, h3DWnd + jne unlock_it + invoke IsIconic, h3DWnd + test eax, eax + jnz unlock_it + call LockMouse3D + ret +unlock_it: + call UnlockMouse3D + ret +UpdateMouseLockState ENDP + HandlePlayerInput PROC uses ebx esi edi local speed:DWORD local nextX:DWORD local nextY:DWORD + local rcClient[16]:BYTE + local ptCenter:C3D_POINT + local ptCursor:C3D_POINT + + ; --- Mouse Look Camera Rotation --- + cmp mouseLocked3D, 1 + jne skip_mouse_look + lea eax, rcClient + invoke GetClientRect, h3DWnd, eax + mov eax, dword ptr rcClient[8] + shr eax, 1 + mov ptCenter.x, eax + mov eax, dword ptr rcClient[12] + shr eax, 1 + mov ptCenter.y, eax + lea eax, ptCenter + invoke ClientToScreen, h3DWnd, eax + lea eax, ptCursor + invoke GetCursorPos, eax + mov eax, ptCursor.x + sub eax, ptCenter.x + test eax, eax + jz mouse_recenter + cmp eax, 64 + jle @F + mov eax, 64 +@@: + cmp eax, -64 + jge @F + mov eax, -64 +@@: + add playerAngle, eax +mouse_recenter: + invoke SetCursorPos, ptCenter.x, ptCenter.y +skip_mouse_look: mov eax, deltaTime3D imul eax, 200 mov speed, eax @@ -5080,6 +5172,7 @@ leave_idle_table: call ClearKeys3D invoke PlayCasinoSound3D, 0, 0, 0 engine_tick: + call UpdateMouseLockState cmp paused3D, 0 jne draw_pause mov eax, deltaTime3D @@ -5342,9 +5435,11 @@ present_frame: invoke Sleep, ecx jmp engine_loop engine_idle: + call UnlockMouse3D invoke Sleep, 50 jmp engine_loop engine_shutdown: + call UnlockMouse3D cmp hRaycastThread, 0 je @F mov bRaycastQuit, 1 diff --git a/poker.exe b/poker.exe index a19b5f5..a6e03f8 100644 Binary files a/poker.exe and b/poker.exe differ diff --git a/poker.obj b/poker.obj index 40b1bc5..cb4c587 100644 Binary files a/poker.obj and b/poker.obj differ