hi all, i'm doing a loop to read a byte state on a particular address. I need to know everytime this byte change. I'm trying with a loop but executing the loop in WM_CREATE the application become locked, paralysed. Is there a way to let the system perform other operations (like DO EVENT command in visualbasic) or is there a way that's more correct to read continuosly this byte ? I wish you're all having a nice assembler christmas time :-) Ciao Angelo
Posted on 2000-12-21 14:45:00 by AnGeLo0110
Well... there is no clean way short of writing a custom VxD to do this, even assuming this location is within your application's own address space. The quick and dirty way is to use a timer and put your read code in it's message or callback handler. However, offhand I can't see why the message loop is crashing, unless you're doing something else wrong (like generating a message!) with your checking routine.
Posted on 2000-12-21 22:13:00 by Ernie
Hmm... looks like Ernie doesn't understand. You mean you want to continuely execute this loop to check these byte in memory right? Well what's happening is you get into your window's message loop and then your first message is WM_CREATE, so you create your controls and execute this loop right. Well this loop starts looping and never returns, so you've never returned from WM_CREATE! There are two ways of beating this, and no not a VxD, you shouldn't use those anyway. The method you choose depends on how acurrately you want the timing. 1.) You use a modified game loop. - In a game wheather you get a message or not you have to be continually looping to update the frames and stuff, often much faster than a windows timer! 2.) Create a seperate thread. - I have never done any multithreading yet, but there is a tutorial on Iczelions site! I'll just show you what I do in my games for a message loop: ;=================================== ; Loop until PostQuitMessage is sent ;=================================== .WHILE TRUE invoke PeekMessage, ADDR msg, NULL, 0, 0, PM_REMOVE .if (eax != 0) ;=================================== ; Break if it was the quit messge ;=================================== mov eax, msg.message .IF eax == WM_QUIT ;====================== ; Break out ;====================== jmp shutdown .endif ;=================================== ; Translate and Dispatch the message ;=================================== invoke TranslateMessage, ADDR msg invoke DispatchMessage, ADDR msg .endif ;================================ ; Call our Main Game Loop ; ; NOTE: This is done every loop ; iteration no matter what ;================================ invoke Game_Main .ENDW So let's analize this loop I've shown you. First off is a while loop, that loops so long as true is true (No how often is that? Forever!) So each time it loops it peeks for a message, this is different from the getmessage api as this one doesn't wait for the next message it checks if there is one and if not returns anyway. After I've checked for messages and handle my windows requiarements, I call my procedure called Game_Main. This procedure is where I check the input for the game, update the characters positions and play sounds. In your case this would check a couple bytes in memory, once it's finished checking it returns to the loop. And then it checks for a windows message, handles it if there is one, checks the byte again, checks for window message, etc... Does that make sense? This is actually a better message loop than this one, which switches into a get message loop when your application minimizes so that it doesn't hog cpu resources, the other option is to only loop like 10-30 times per second, instead of as fast as the cpu can go. Hope this helps you out! See ya, Ben
Posted on 2000-12-21 22:55:00 by cyberben
Many thank for your very very precious help. Mow my program work fine, with a continuos loop that chek my byte ! Ciao nad many thanks again Angelo :&)
Posted on 2000-12-23 08:03:00 by AnGeLo0110