[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Programming Question
- Subject: Re: Programming Question
- From: retromod-Apple-II-newsgroups; rm -rf ~;@vuse.vanderbilt.edu (Tilghman Lesher)
- Date: 1997/11/29
- Newsgroups: comp.sys.apple2
- Organization: Vanderbilt University School of Engineering, Nashville, TN, USA
- References: <1d8_9711291213@ima.infomail.com>
Robert Fletcher (Robert.Fletcher@311.ima.infomail.com) wrote:
: I am studying structure design for programming. This is a home project not
: school work. I have been using some of my old books and rewritting then into a
: structure design form.
: Enough about me, now my question. How can I, in Applesoft Basic, get input
: from the keyboard with out stopping the program? If Basic can not do this, then
: just let me know. I will be working on assembly, after I have master the art of
: structure design.
In Applesoft BASIC, it is nearly impossible were it not for the PEEK and
POKE commands.
What you need to do is to program a loop, either a GOTO, if you need a main
programming loop or a FOR if you want timed response. Inside the loop,
place the following code (or GOSUB to it, if you want).
IF PEEK(-16384) > 128 THEN KEY$ = CHR$(PEEK(-16384)):POKE -16368,0
Remember to clear KEY$ before you call the routine and preinitialize
the routine (at the beginning of your program) with a POKE -16368,0
Essentially, this routine accesses the keyboard strobe. The keyboard
strobe contains the last key pressed with the high bit (bit 7) set if
the key was pressed after the last time you cleared the strobe. In
assembly, the strobe is at $C000, while the location to clear the
strobe is at $C010.
It is important to clear the strobe after you read it, otherwise
a single keypress will show up as multiple keypresses.
Remember also that since Applesoft BASIC is an interpreted language,
timing loops which are good to the second are not possible. You'll
have to settle for approximate timing or else change your program
to assembly to ensure timing accuracy.
--
__ __|_) | |
| | | _` | \ ` \ _` | \
_| _|_|\__, |_| _|_|_|_|\__,_|_| _|
____/