is there something wrong with the code below? the program quits when i press a key.
===============================================
.data
key db 256 dup(0)
.code
...
...
mainloop proc hwnd1:dword,umsg:dword,wparam:dword,lparam:dword
...
...
.elseif umsg == WM_KEYDOWN
mov key[wparam],1
return 0
.elseif umsg == WM_KEYUP
mov key[wparam],0
return 0
...
...
mainloop endp
assuming that is a dialogproc then when you process a message you should return true. although i'm not quite sure what you're even doing.. what is key[wparam]. for all i know that mov is causing a crash
My assumption is it is a byte array from a nehe tutorial so key state can be queried easily
i am trying to make room to store key info - 256 bytes in mem.
then when a key is down, the corresponding mem is changed to value 1.
i found some C syntax in http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01
case WM_KEYDOWN:
{
keys[wParam] = TRUE;
return 0;
}
case WM_KEYUP:
{
keys[wParam] = FALSE;
return 0;
}
then i tried to convert these into ASM.
Some of the tutorials are already in MASM syntax have a look at some of the next ones
that's good. but i am learning ASM, so i don't intend to simply copy codes from tutorials, i am trying to write every line by myself.
That's ok but rather than post the question on the forum you might be better served looking in one of those example files....
Also you should comment out those lines and test the app.... I dont see an error there so there may well be an error some place else in your app that is simply caught when you press a key.... I (used to :/) get caught out with register preservation a lot ie the USES esi edi etc bit of the proc....
I learnt partially off examples in masm whilst I knew how to code c.... this way you will not get hung up on minor syntax issues
EDIT: er I use different syntax so I would type:
mov eax, wParam
mov Keys[eax], 1
Maybe this is issue
The nehe tutorials are rather basic so dont think of looking at the masm code as cheating :bg it is far better to concentrate on the concepts of 3D/windows etc and the syntax of asm seperately.... You are not doing yourself any favours lumping them all in together
that's the exact issue. :lol
thanks!
This had confused me in the past and maybe someone could correct me if I'm wrong but if you do this
mov Label, 2
mov eax, Label
mov Keys[eax], 1
it is different from
mov Label, 2
mov eax,
mov Keys[Label], 1
The second example label is the address? I think rather than the value.... I havent clicked as to conceptually why it is with this syntax
Quote from: oex on May 06, 2010, 08:02:33 PMmov Keys[Label], 1
I'm sure this will generate ab error, because your are trying to add tow labels for addressing.