Hi!
I am working on a system managing key presses in a MASM application. The problem is that I must be doing something wrong with the array that keeps the press status of each key. (bool g_keys[256] // Position 0x20 means VK_SPACE i e.)
The "input_set_key" function always returns a non-zero value like my memset hasn't done anything with the array.
What can be the problem? I can't see it...
Thanks alot for your helpfulness!
/Klarre
.data
g_keys dd 0 ; Pointer to the array of keys
.code
; ------------------------------------------------------------------------------
input_create proc
invoke crt_malloc, 256 ; Allocate 256 Bytes for the key array
mov g_keys, eax ; Store the key array pointer
invoke crt_memset, g_keys, 0, 256 ; Make sure no buttons are pressed
invoke input_is_key_pressed, 27 ; DEBUG TEST. Returns a non-zero value
xor eax, eax
ret
input_create endp
; ------------------------------------------------------------------------------
input_is_key_pressed proc key:dword
lea eax, [g_keys] ; Get the key array address
add eax, key ; Offset to the correct position in the array
mov eax, [eax] ; Read the value on the position in the array
ret
input_is_key_pressed endp
end