[net.micro.apple] Bell char in VTP on Apple ][

zben@umcp-cs.UUCP (06/11/84)

Seems to me one could do the speaker tweaking without slowing down the
VTP (virtual terminal program) in the following way:

When a bell char comes in, put a selected non-zero value in a global
cell.  The value determines the bell length.

In the "main loop" of the program, typically:

   DO FOREVER
      IF <anything in serial line uart receiver> THEN
         <Display one character on screen (or function, or whatever)>
      IF <anything in keyboard input port> THEN
         <Send char to serial line, maybe echo>
   ENDDO

put in a test that, if the global cell is nonzero, "touch" the speaker
toggle and decrement the global cell.  Eventually the cell will be 
decremented to zero again, and the bell will stop.

If another bell comes in during this interval, one can stuff the constant
into the cell again, and get a slightly longer bell.

If the main loop is very short you might only want to do this every
"N"-th time through the loop.  You also might want to uncouple the
time constants for the "touch" and the decrement, for example, touch
the speaker every 10 times through but only decrement every thousand
times through.

Extending this scheme to have several bells of different duration and
frequency are left as exercises to the student... :-)

The problem with linefeeds is much harder since you have to decide what
to do if you get a linefeed during a scrolling operation.  At the worst
case (scrolling a screen all the way with linefeeds) you could actually
clear the screen and be done with it!  Seems to this humble hacker that
there should be a data structure in which you could modify the information
on the fly (between row-moves) and restart the algorithm.  Something like
"gosh, we have 3 linefeeds at this point, so this row needs to go *here*".
I haven't really thought about it that much...
-- 
Ben Cranston   ...seismo!umcp-cs!zben      zben@umd2.ARPA