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

Re: Apple II Random Events?



Paul Guertin (pg@sff.net) wrote:
: dalloff@freenet.columbus.oh.us (Dave Althoff) wrote:

: > : > 50 REM GET A KEY (RETURNS ASCII CODE IN AC)
: > : > 60 ZZ= RND(1): ZZ= PEEK(49152): IF ZZ<128 THEN 60
: > : > 70 AC= ZZ-128: ZZ= PEEK(49168): RETURN
: > 
: > A quick trick for Applesoft programmers waiting for a keypress...

: Nice trick, Dave. For a no-frills "wait for keypress", I usually
: did something like this:

: 60 WAIT -16384,128: GET C$: RETURN

: I've met many Applesoft programmers who, for some reason, had 
: never heard of the WAIT instruction.

I have done that, but usually my reason for reading the keyboard directly
instead of using GET is because I want to do something else while
waiting...providing my own input cursor is a good example.  So I seldom
use WAIT.

: For extra credit, can you think of a situation where the optional
: third argument to WAIT is useful?

That would allow you to wait for a *particular* value.  The expression you
describe, WAIT -16384,128,0, checks only one bit.  Using the third
argument allows you to still check only one bit (using 128 for the second
argument) but specifying an alternate bit pattern that you are actually
looking for.  So WAIT -16384,128,160 will wait until the SPACE BAR is
pressed.  This is useful because WAIT -16384,160,0 will wait for any
keypress with an ASCII value greater than 32, since non-specified bits in
the second argument are not checked.

It was a guess...how did I do?  8-)

--Dave Althoff, ][.
-- 
    /^\        _       _            *** Closed for the season 8-( ***
   /XXX\      /X\     /X\_      _     /X\__      _     _        _____  
  /XXXXX\    /XXX\  _/XXXX\_   /X\   /XXXXX\    /X\   /X\      /XXXXX
_/XXXXXXX\__/XXXXX\/XXXXXXXX\_/XXX\_/XXXXXXX\__/XXX\_/XXX\_/\_/XXXXXX