EBLAN_ENGINE/include/engine_input.inc

83 lines
2.1 KiB
HTML

; ==============================================================================
; EBLAN ENGINE - Input System (Keyboard via GetAsyncKeyState)
; ==============================================================================
.code
; ------------------------------------------------------------------------------
; PollInput: Reads keyboard state and updates movement & action flags
; ------------------------------------------------------------------------------
PollInput PROC uses eax ebx
; 1. Forward (W / Up Arrow)
invoke GetAsyncKeyState, VK_KEY_W
mov bx, ax
invoke GetAsyncKeyState, VK_KEY_UP
or bx, ax
test bx, 8000h
setnz keyForward
; 2. Backward (S / Down Arrow)
invoke GetAsyncKeyState, VK_KEY_S
mov bx, ax
invoke GetAsyncKeyState, VK_KEY_DOWN
or bx, ax
test bx, 8000h
setnz keyBackward
; 3. Strafe Left (A)
invoke GetAsyncKeyState, VK_KEY_A
test ax, 8000h
setnz keyStrafeLeft
; 4. Strafe Right (D)
invoke GetAsyncKeyState, VK_KEY_D
test ax, 8000h
setnz keyStrafeRight
; 5. Turn Left (Left Arrow)
invoke GetAsyncKeyState, VK_KEY_LEFT
test ax, 8000h
setnz keyTurnLeft
; 6. Turn Right (Right Arrow)
invoke GetAsyncKeyState, VK_KEY_RIGHT
test ax, 8000h
setnz keyTurnRight
; 7. Action / Open Door (E / Space)
invoke GetAsyncKeyState, VK_KEY_E
mov bx, ax
invoke GetAsyncKeyState, VK_KEY_SPACE
or bx, ax
test bx, 8000h
setnz keyAction
; 8. Run / Sprint (Shift)
invoke GetAsyncKeyState, VK_KEY_SHIFT
test ax, 8000h
setnz keyRun
; 9. Toggle Minimap (M - single press trigger)
invoke GetAsyncKeyState, VK_KEY_M
test ax, 0001h ; Check if key was pressed since last call
jz @F
xor keyShowMap, 1
@@:
; 10. Screenshot (F12 - single press trigger)
invoke GetAsyncKeyState, VK_KEY_F12
test ax, 0001h
jz @F
mov keyScreenshot, 1
@@:
; 11. Escape - Exit application
invoke GetAsyncKeyState, VK_KEY_ESCAPE
test ax, 8000h
jz @F
mov isRunning, 0
@@:
ret
PollInput ENDP