![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 291
Rep Power: 4
![]() |
[MASM32] Working with arrays
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
__________________
http://www.klarre.se Last edited by Klarre; Mar 3rd, 2008 at 2:58 PM. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| joining associative arrays | MiKuS | PHP | 2 | Sep 6th, 2007 2:20 AM |
| Confusion With Pointers and Arrays | JawaKing00 | C | 10 | Sep 14th, 2006 7:33 AM |
| Arrays or Vectors? | can342man | C++ | 2 | Apr 20th, 2006 3:57 PM |
| Arrays in PHP | MrMan9879 | PHP | 6 | Jan 12th, 2006 9:18 PM |
| Arrays | Gunman | C++ | 17 | Oct 20th, 2005 6:11 AM |