[comp.sys.handhelds] Terminal emulator

bgribble@jarthur.Claremont.EDU (Bill Gribble) (07/27/90)

In article <8534.26af45fa@ohstpy.mps.ohio-state.edu> kramer@ohstpy.mps.ohio-state.edu writes:
>Does anyone know of a dumb terminal program for the HP48sx?  

Here's the one I wrote and used for a while.  It's pretty slow, but it 
  works ok.  The functions are mostly in the comments, and you might need
  to know that orange shift = shift, blue shift = control.  

The only reason I'm posting this is that I've read and answered several 
  requests like this in the past few days.  I f anyone has any questions, 
  just email.  I'm having a quite boring summer, so I don't have anything
  better to do.  Anyway, here it is.

I have a feeling news may not handle the keys file too well; I broke it 
  up[ into several lines, but it should be 1 long one.  The control 
  characters will most likely screw something up, but I'm too lazy to
  fix it (since I don't have a 48 currently anyway).  Here's how, though:
  replace all the control characters with a sequence of the form \###, where
  ### is the ascii (or hpascii, at least) code of the control character.
  cntrl-a, for example, is \001, cntrl-M is \013, etc.

Good luck.

                                       Bill.

======================================= cut here ===========================

keys - term2.1 keymap file.

%%HP: T(3)A(R)F(.);
"..........ABCDEF....GHIJKL....MNOPQR....STUVWX....
.\<)$%^].....\x-!@#'......),?~........................
..........
............................abcdef....ghijkl....mnopqr....stuvwx....
.....\.V789/.....\<)456*.....\x-123-......0. +"


term2.1 - dumb terminal emulator for the hp48

%%HP: T(3)A(R)F(.);
\<< "" ""                @ initial values for some variables - string and line.
  \<<                    @ write: the string display program.
    WHILE DUP SIZE       @ DISP's the string it's given in chunks of 21.
21 >
    REPEAT DUP 1 21      @ shows string by 21's
SUB 7 DISP nl DUP        
SIZE 22 SWAP SUB    
DUP 'line' STO 
    END 7 DISP           @ shows the last < 21 char bit
  \>>
  \<< NUM \-> nbr        @ cntrl: deals with control-type characters.
    \<<
      CASE nbr 8 ==      @ deletes 1 char from the string
        THEN string
DUP SIZE 2 - 1 SWAP
SUB 'string' STO
string write
        END nbr 13       @ screen cr
==
        THEN nl ""
'line' STO
        END nbr 7        @ beep on control - G
==
        THEN 1000
.2 BEEP
        END
      END
    \>>
  \>>
  \<< DUP NUM \->        @ snd - send a character.  
outkey nbr               @ really deals with program control characters
    \<<                  
      CASE nbr DUP
128 < SWAP 13 \=/ AND    @ gets a normal char out
        THEN outkey
XMIT DROP
        END nbr 13       @ pads cr's with lf's
==
        THEN outkey
10 CHR + XMIT DROP
        END nbr 128      @ orange-shift flag
==
        THEN 2 CF
          IF 1 FS?
          THEN 1 CF
          ELSE 1 SF
          END
        END nbr 129      @ blue-shift flag 
==
        THEN 1 CF
          IF 2 FS?
          THEN 2 CF
          ELSE 2 SF
          END
        END nbr 130      @ alpha key: send break
==
        THEN SBRK
nl
"  -- Break sent --"
write
        END nbr 131      @ quit: del key
==
        THEN 4 SF
        END nbr 132      @ control - backspace: start kermit send  
==
        THEN kermit
        END nbr 133      @ shift - backspace: kermit receive
==
        THEN RECV
        END nbr 134      @ toggle buffer dump: shift - alpha
==
        THEN
          IF 5 FS?
          THEN 5 CF
          ELSE 5 SF
          END
        END
      END
    \>>
  \>>
  \<< LCD\-> { # 0h      @ newline
# 8h } { # 83h
# 37h } SUB # 83h
# 40h BLANK { # 0h
# 0h } 3 ROLL GOR
\->LCD "" 'line' STO
  \>>
  \<<                    @ kermit send: send [filename]
"Term 2.1 Kermit Send"
"File name:" INPUT
DUP SIZE 11 SWAP
SUB "'" + "'" SWAP
+ STR\-> SEND CLLCD 2
CF TERM2.1                @ cheesy way to get back in program
  \>> 'kermit' STO        @ program startup shit
'nl' STO 'snd' STO
'cntl' STO 'write'
STO 'string' STO
'line' STO 1 CF 2
CF 3 CF 4 CF CLLCD
  DO BUFLEN               @ check for incoming characters 
    IF DROP DUP 
    THEN                 
      IF DUP 40 > 5       @ dump buffer if toggle set 
FS? AND
      THEN BUFLEN
DROP SRECV DROP2
      ELSE ""             @ clear string buffer
'string' STO 1 SWAP
        FOR dobuf 1       @ read 1 char at a time
SRECV DROP
          IF DUP          @ if it's not a control character
NUM 31 >             
          THEN            @ sto+ it in the string
'string' SWAP STO+
          ELSE
'line' string STO+
line write cntl ""
'string' STO
          END
        NEXT 'line'       @ make sure to start writing at old text pos
string STO+ line
write
      END
    ELSE DROP
    END KEY               @ read keyboard input
    IF
    THEN \-> k
      \<<
        CASE 1 FS?
          THEN 0
          END 2 FS?
          THEN 1
          END 1 FS?
2 FS? AND NOT
          THEN 2
          END
        END 100 * k
+ keys SWAP DUP SUB
snd
      \>>
    END
  UNTIL 4 FS?
  END { cntl snd
write string line
kermit nl } PURGE
CLOSEIO 1 CF 2 CF 3
CF 4 CF 5 CF
\>>