Re: LZ: TimeOut routines


[Prev][Next][Index][Thread]

Re: LZ: TimeOut routines



Try this Mike:
(Routine snippet from KCLock85)
----
;*********************************************************************
********
;****** Creates an interruptable loop for a short time (a = Scan 
code) *******
;*********************************************************************
********
Delay:
	push hl
	ld  de,0                           ; Reset the "timer"

Label4DelayLoop:
	call get_key
	or  a                     ; checks if a=0 (mentioned earlier)
	jr  nz,KeyPressed         ; jumps if a key was pressed
	inc de                    ; otherwise we inc the "timer"
	ld  hl,$FFFF              ; set the value to compare the "timer" to
	call CP_HL_DE             ; and check if they're equal
	jr  z,TimeOut             ; if they were equal, we jump
	jr  Label4DelayLoop       ; otherwise, we loop back

TimeOut:
	ld  a,255
;    jr  EndDelay

KeyPressed:    
EndDelay:    
	pop hl

	ret
----
That will wait for a key for a while (5-10 secs?) then, if no key was 
pressed, it will return a value of 255 in the accumulator.  Otherwise 
the scancode of the key will be in the accumulator.

Cheers,

____
~Keith
FFNP69C@PRODIGY.COM
http://pages.prodigy.com/FFNP69C/