*******************
DTERM V1.0 10.01.91 By Glenn G. Bruckno
*******************

[ MJH: This program displays incoming data when it has received CRLF,
       Most MSDOS based computers don't send those charachters when
       you press ENTER, so nothing is displayed. In TELIX, a well
       known terminal program for the MSDOS pc you can easily define
       the ENTER key to send a CR and LF (^M and Alt-10).
]


THE POOP ON DTERM
-----------------
DTERM is a dumb terminal emulator for the HP48.  I posted it here 
because I couldn't find any other terminal emulator which completely 
fit my needs.  It was written for a very specific work-related 
application; as such, it may need tailoring for your particular use. 
Fortunately, it is written without machine code and is easily modified.

DTERM has some distinct advantages over the other terminal emulators 
I've seen here on the BBS, including a true 10 line scrolling display.
Its big advantage is the ability to handle huge amounts of incoming
data, even at 9600 baud.  DTERM needs only the briefest of occasional 
pauses from the host in order to buffer data.  Provided the HP returns
now and then from performing its own serial housekeeping, the amount 
of data that can be buffered is limited only by available memory.

THE POOP ON THE PROGRAMS
------------------------
Download the following binary attachment and you will see the 
following appear in your current directory:

TERM
A Directory consisting of the following programs:

                                                     Stack action
                                                     ------------
     DTERM     The main program,                      --  |  --
               Saves your flags,
               creates temporary globals
               CRLF: A string "<cr> <lf>"
               INLN: An empty string: ""
               examines BUFLEN and assembles
               serial data INLN
               Restores your flags and
               purges temporary globals
               on exit

     DOKEY     Routines for handling                  --  |  0/1
               a keypress.  Returns 1
               if the DEL key is pressed
               which ends the program,
               0 otherwise

     SCROLL    Scrolls PICT up one line               --  |  --
               (6 pixels)

     PUTLN     Takes a string from Level         "string" |  --
               1 and puts it on the bottom
               of PICT

     STRIP     Removes characters from                --  |  --
               incoming string INLN
               up to <cr> <lf>; calls 
               SCROLL, passes string
               to PUTLN

Now for its limitations:  Because DTERM turns incoming ASCII into 
graphic objects for its display, each line should not exceed the 
width of PICT.  In other words, the line width measured in terms of
characters depends on the pixel width of the characters displayed.  
You can fit a whole bunch of i's across the display; not so many w's.  
If a line is received which exceeds this, the excess is lopped off 
into pixel oblivion.  

In addition, DTERM waits for a <cr> <lf> pair to be received before 
it displays any preceding characters.  The <cr> <lf> is stripped off; 
no other controls are stripped.  If your application is packet radio, 
tell your fellow packeteers to send short lines!

You can remove both these limitations by modifying STRIP to simply wait
for an arbitrary number of characters (i.e., examine the SIZE of INLN)
before executing SCROLL and PUTLN.  You will have to decide on a
reasonable columnar display width.  

If your host sends only <cr> at the end of a line, modify STRIP thusly:

change PUTLN 2 + to
       PUTLN 1 +

Also, remove the 10 CHR + part from DTERM (the linefeed char).

CREDIT WHERE CREDIT IS DUE
--------------------------
Thanks to Mr. Kevin Jessup for the keytable idea from his excellent 
program DTE48.  I've hacked it for my purposes, so the following 
changes are noted:

1. Default is upper case.
2. No more toggle flag -- if you hit a gold 
   or blue key once, it can't be undone.
3. Alpha key eliminated -- I don't try to
   throttle the host.

THE POOP ON USING DTERM
-----------------------
Set up your serial I/O with the standard HP I/O SETUP menu.  Press 
DTERM to run.  Press letter keys to send characters.  Press <left shift> 
to change the next character to lower case.  Press <right shift> to 
change the next character to a Control character: A becomes ^A etc.
Press ENTER to send a <cr>; <left shift> ENTER sends a <lf>. Unassigned
keys shoot blanks. Press DEL to quit. 

You can test DTERM in standalone mode by looping the serial connector 
back to itself: jump the middle two pins on the serial connector.
Remember to set wire mode in the I/O SETUP menu.

Because the SCROLL and PUTLN routines juggle graphic objects, they
take a lot of time to execute.  Therefore DTERM assigns high priority
to the incoming data.  SRECV is performed any time BUFLEN is nonzero.
Only when BUFLEN is zero, meaning no characters are staged for reception,
do SCROLL and PUTLN perform.  Even then, only one line is manipulated 
before BUFLEN is again examined.  Rest assured that your characters
are being buffered even though no data may appear on the display for 
a while.  When the host takes a breather, the data will scroll onto 
the display slowly enough to read.

I have reproduced here Mr. Kevin Jessup's translation table, modified:

KEY        UNSHIFTED RESULT   LEFT SHIFTED RESULT   RIGHT SHIFTED RESULT
--------   ----------------   -------------------   --------------------
A          A                  a                     ^A (ASCII 1)
B          B                  b                     ^B (ASCII 2)
C          C                  c                     ^C (ASCII 3)...

Z          Z                  z                     ^Z (ASCII 26)

1          1                  !
2          2                  @
3          3                  #
4          4                  $
5          5                  %
6          6                  ^
7          7                  &
8          8                  *
9          9                  (
0          0                  )
/          /                  ~
*          *                  ,
-          -                  _    (underscore)
+          +                  =
.          .                  <
SPC        space              >
<-         backspace          delete
ENTER      carriage return    linefeed
DEL        QUIT               QUIT

OTHER POOP
----------
I have posted this program here so as to provide a tool for other 
HP48 bitheads.  Examine the code, change it, improve it, have a 
blast.  In exchange, I ask you to likewise upload your interesting
stuff for the overall good of mankind.  However, please give credit 
where credit is due, and if you find a way to make money with my code, 
my ugly lawyers and I will demand some fat royalties.  

Send comments, questions, etc to me:

here under the name:            ggbruckno
or via packet radio:            KB2HBW @ W2EMU-4.NJ.USA.NA

