Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 3rd, 2008, 2:34 PM   #1
Klarre
Game engine designer
 
Klarre's Avatar
 
Join Date: May 2005
Location: Sweden
Posts: 291
Rep Power: 4 Klarre is on a distinguished road
[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.
Klarre is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC