Re: LZ: TimeOut routines
[Prev][Next][Index][Thread]
Re: LZ: TimeOut routines
On Sun, 15 Dec 1996 22:45:02 -0800,
Alan Bailey wrote...
>Michael Wyman wrote:
>>
>> Can any of you tell me how I would run a timeout routine in a program
>(such
>> as having the calculator turn itself off if a key wasn't pressed in
after
>> a certain amount of time)? I can't seem to get it to work correctly!
>>
>> This is about what I've tried so far:
>>
>> ld bc, $ffff
>> Loop:
>> call GET_KEY
>> dec bc
>> jr z, Time_Out
>> or a
>> jr z, Loop
>> ret
>>
>
>Well, the "or a" isn't needed because all that will do will or a with
>itself, leaving a.
Using "or a" will return a, but it will also set the zero flag if a=0. That
is what I was using it for. It's a byte smaller than "cp 0", and does the
exact same thing. So if no key is pressed, the calculator will loop back
to 'Loop'.
With regards to the 'call GET_KEY' and what registers it affects, I believe
that it only changes hl. Generally, I push hl to the stack before using
call GET_KEY (though I normally use a subroutine to wait for keypresses),
but this time, nothing really valuble was stored in hl, so I didn't bother
to save hl (why waste RAM?).
Thanks,
Michael Wyman - SeaHorse Software
wyma0012@gold.tc.umn.edu
Follow-Ups: