From bgribble@jarthur.Claremont.EDU Fri Apr  6 22:35:27 1990
From: bgribble@jarthur.Claremont.EDU (Bill Gribble)
Newsgroups: comp.sys.handhelds
Subject: hp48 terminal emulator: here it is!
Keywords: slow as a pig with gland problems.
Date: 3 Apr 90 18:00:19 GMT
Organization: Harvey Mudd College, Claremont, CA 91711

Well, here it is: my humble effort at an hp48 terminal emulator.  It works,
  but that's about it.  I'm still (as I posted yesterday) looking for faster
  screen display routines, since this version loses text when it's sent
  in blocks of more than about 20 characters - i.e., all the time.

I know it's functional because I used it to upload itself to this computer;
  kermit is much more functional when you skip the pc step in the
  ftp-to-unix <=> zmodem-to-pc <=> kermit-to-calc cycle, and it's pretty
  impressive to see a 'username>' prompt on a calculator screen. 

Features:  semi-functional kermit shell: it receives right, but there's
  an unknown (and moronic, I'm sure)  bug in the send program.  Invocation:
  orange-shift backspace to send (it'll prompt you for a filename and do zip),
  blue-shift backspace to receive.  In general, blue-shift is for SHIFT, 
  orange shift is CNTRL. They're both toggles: once to start, again to enter 
  normal text.  The alpha key sends a serial break.  DEL quits the program 
  and cleans trash.
    
I haven't actually implemented the XON/XOFF flow control I mentioned
  yesterday; that's version 1.1, I guess.  Other needs: punctuation marks;
  they're destined to be shifted numbers.  Faster text display: I'm trying
  out a few different things today.  

Sorry the thing is such a beast; I put it in one program to speed up 
  the upload/edit/download/etc., so it takes twice as much memory
  when it runs.  Easy to change, but editing the thing on the 48 is 
  REALLY slow, so I'm doing the big revisions on the computer now that
  I fixed my cable.

Have fun; any advice/suggestions are appreciated.

                                        Bill.

=============================================================================  
=====   Bill Gribble           Internet: bgribble@jarthur.claremont.edu =====
=====   Harvey Mudd College              wgribble@hmcvax.claremont.edu  =====
=====   Claremont, CA 91711    Bitnet:   wgribble@hmcvax.bitnet         =====
=====   (714) 621-8000 x2045                                            =====
=============================================================================

=============================================================================

TERM 1.0: hp48 terminal emulator.  
Bill Gribble.

 BYTES: 2181
CHKSUM: # 2A05h

%%HP: T(3)A(R)F(.);
\<<
  \<<
    IF DUP NUM 31 \<=
    THEN
      IF DUP NUM 8
==
      THEN string
DUP SIZE 1 - 1 SWAP
SUB 'string' STO
DROP ""
      END
      IF DUP NUM 13
==
      THEN 'string'
empt STO+ DROP ""
      END
    END 'string'
SWAP STO+ string 7
DISP
    IF string SIZE
21 \>=
    THEN LCD\-> {
# 0d # 8d } {
# 131d # 55d } SUB
# 131d # 64d BLANK
{ # 0d # 0d } 3
ROLL GOR \->LCD ""
'string' STO
    END
  \>>
  \<<
    IF DUP NUM 128
<
    THEN
      IF DUP NUM 13
==
      THEN 10 CHR +
      END XMIT
    ELSE DUP NUM
'nm' STO
      IF nm 128 ==
      THEN
        IF 27 FS?
        THEN 27 CF
26 CF
        ELSE 26 CF
27 SF
        END
      ELSE
        IF nm 129
==
        THEN
          IF 26 FS?
          THEN 26
CF 27 CF
          ELSE 26
SF 27 CF
          END
        ELSE
          IF nm 130
==
          THEN SBRK
empt wrt
"   -- Break sent --"
wrt
          ELSE
            IF nm
132 ==
            THEN
krm
            ELSE
              IF nm
131 ==
              THEN
quit
              ELSE
IF nm 133 ==
THEN RECV
END
              END
            END
          END
        END
      END
    END
  \>>
  \<< 13 CF 14 CF
    DO BUFLEN KEY
DUP
      IF 0 \=/
      THEN 13 SF
DROP 'k' STO
      ELSE DROP
      END
      IF DROP 0 \=/
      THEN 14 SF
      END
    UNTIL 13 FS? 14
FS? OR
    END
    IF 13 FS?
    THEN
      IF 27 FS?
      THEN 2
      ELSE
        IF 26 FS?
        THEN 1
        ELSE 3
        END
      END 'keys'
SWAP GET k k SUB
snd DROP
    END
    IF 14 FS?
    THEN BUFLEN
DROP
      IF DUP 20 >
      THEN DROP 21
      END SRECV
DROP wrt
    END term2
  \>> {
"..........ABCDEF....GHIJKL....MNOPQR....STUVWX....YZ\v/\GS.....\.V789......\<)456*.....\x-123-......0. +"
".............. 	.  .............\v/\.S.....\.V.........\<).........\x-................."
"..........abcdef....ghijkl....mnopqr....stuvwx....yz\v/ .....\.V789......\<)456*.....\x-123-......0. +"
}
"                      "
  \<< 19 CHR XMIT
DROP empt wrt
"File: " wrt 0 \-> q
    \<< ""
      DO
        DO KEY
        UNTIL
        END
        IF DUP 51
SAME
        THEN 1 'q'
STO+
        ELSE keys 1
GET SWAP DUP SUB
DUP wrt +
        END
      UNTIL q
      END
    \>> DROP 17 CHR
XMIT DROP STR\-> SEND
  \>>
  \<< { k nm string
krm empt keys term2
snd wrt quit }
PURGE CLOSEIO
  \>> 'quit' STO
'krm' STO 'empt'
STO 'keys' STO
'term2' STO 'snd'
STO 'wrt' STO CLLCD
"" 'string' STO
OPENIO 13 CF 14 CF
27 CF term2
\>>

