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

Re: Programming Question



Adam Myrow (hurry@imap2.asu.edu) wrote:
: When I want a "PRESS ANY KEY" routine, I figure that something might as well
: happen if the program is going to be running.  Here is my routine.

: 140 PRINT "PRESS ANY KEY TO CONTINUE..."
:  150 A =  RND (1)
:  155  IF  PEEK ( - 16384) < 128 THEN 150
:  160  GET A$

(etc)

Well, I also make use of the time, but not usually for seeding the RNG.

First of all, most of the programs I have written make use of the
80-column display.  And I happen to like blinking-underline cursors.  So I
create my own:

REM During initial setup, C$(0)="_"; C$(1)=" ".
REM Get one character of input:
60000 CM=0:DL=150
60001 VTAB V:POKE 36,H:?C$(CM);:KB%=PEEK(-16384):ON KB%>128 GOTO
      60002:DL=DL-1:ON DL GOTO 60001:CM=NOT(CM):DL=150:GOTO 60001
60002 KB%=KB%-128:Q1$=CHR$(KB%):POKE -16368,0:RETURN

I also have a nostalgic streak.  Does anyone remember the Qube system that
Warner-AMEX Cable came up with many years ago?  They introduced it in 1977
here in Columbus, OH, and it spread to a number of other cities before it
was shut down.  Anyway, that system allowed for audience response through
five buttons on the cable box.  In honor of that system, when I am simply
waiting for the user to make a choice from a menu, in addition to
displaying the cursor at the data input position, I also have been known
to flash...
                          TOUCH NOW
at the bottom of the screen.  Cooler still...the cursor and the message
flash at different rates!

Yet another program...that I wish I could find; I seem to have misplaced
the disk...also in Applesoft...contains a IIgs toolbox call.  Well,
actually the program is smart enough to figure out what kind of machine it
is running on.  If it is running on a //e, it just flashes the cursor. 
But if it is running on a IIgs, the cursor routine calls a short assembly
routine, which reads the GS clock.  Then the cursor routine displays the
date and time at the bottom of the screen.

In fact, if you are writing any program that has to handle background
tasks, this is what you *must* do on the Apple ][, since it doesn't have
any mechanism in place (at least not that Applesoft programmers can use)
for handling multiple processes.  So, if you have a program that is
supposed to be, say, operating a real-world device and still allowing for
manual input, you use the keyboard input routine to build your own event
queue.  Voila:  Rudimentary cooperative multitasking...from BASIC!

--Dave Althoff, ][.
-- 
    /-\        _       _       ***  Thanks for a great season!!!  ***
   /XXX\      /X\     /X\_      _     /X/|_      _     _        _____  
  /XXXXX\    /XXX\  _/XXXX\_   /X\  <#&/XXX\    /X\   /X\      /XXXXX
_/XXXXXXX\__/XXXXX\/XXXXXXXX\_/XXX\_o==oXXXX\__/XXX\_/XXX\_/\_/XXXXXX