Hello :) I am working on an assembly game (big task for an assembly newbie like me), and I'm wondering if it's possible to both keep time and wait for user input at the same time.
This is how I keep time: get system time, save the unit for second. Then keep getting system time until the second you get is different from the second you saved. Then you'll know one second has passed. It counts down from WAITINGTIME to 0, then does something.
@TIMELOOP:
MOV AH, 2Ch
INT 21h
MOV SECOND, DH
@WAIT1SEC:
MOV AH, 2Ch
INT 21h
CMP SECOND, DH
JE @WAIT1SEC
DEC WAITINGTIME
CMP WAITINGTIME, 0
JNE @TIMELOOP
; WAITINGTIME seconds have passed, do something
And this is how I wait for user input: keep reading keyboard input until a key is pressed. The game needs a moving cursor, so basically it responds to the WASD keys. Once a key is pressed, I move the cursor accordingly.
@READKEY:
MOV AH, 06h
MOV DL, 0FFh
INT 21h
JZ @READKEY
; work with the pressed key
I wonder, is it possible to merge these two codes together? I need the player to be able to keep moving the cursor, but I also need to keep track of the time. It doesn't seem like I can put both in one loop :/ Keeping both in one loop will stop the timekeeping when the pressed key is processed.
Oh yeah, I'm working in Windows using MASM.
Any ideas? It would be great if there was a really simple way to do this...as I don't have much assembly knowledge :( Thanks in advance for any help!