News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help Please.

Started by merak316, January 20, 2007, 10:53:59 PM

Previous topic - Next topic

merak316

#15
edit

MichaelW

You are not doing what I thought you were doing. Without a window, message loop, and window procedure you cannot receive WM_TIMER messages, unless you set up a specific callback function to handle the messages (TimerProc in the documentation). This is doable, but it would probably be easier to implement something like this pseudo-code:

OuterLoop:
  tickCount = GetTickCount
  Generate random number between 1000 and 3000
  terminalCount = tickCount + random number
InnerLoop:
  ...
  poll keyboard, etc
  ...
  tickCount = GetTickCount
  if tickCount > terminalCount then
    simulate press of spacebar
    goto OuterLoop
  end if 
  goto InnerLoop
eschew obfuscation

merak316

#17
edit

sinsi

merak316, what exactly are you trying to do with your code? Right now, it seems to go nowhere - if you tell us
what your goal is, we could help you more (I think) e.g. why do you need the space bar pressed?
Light travels faster than sound, that's why some people seem bright until you hear them.

merak316

#19
edit

MichaelW

You are getting descriptions and pseudo-code instead of code because this looks like homework. You can generate the random number as I described, by calling nrandom. To understand why the timer is not working, and cannot work with your code, try the MSDN link that I provided.

If instead of:

.486
.model flat, stdcall
option casemap :none

include      C:\masm32\include\windows.inc
include      C:\masm32\include\kernel32.inc
include      C:\masm32\include\user32.inc
includelib   C:\masm32\lib\kernel32.lib
includelib   C:\masm32\lib\user32.lib

You use just:


include \masm32\include\masm32rt.inc


Then you will be able to use the MASM32 macros and functions to display the value of registers, variables, etc. This will allow you to monitor what the code is actually doing, instead of having to guess.
eschew obfuscation

merak316

#21
edit

mnemonic

Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

merak316

#23
edit