[comp.sys.handhelds] DEC VT 52 Terminal Emulator for HP48SX

eldorado@en.ecn.purdue.edu (David D Jansen) (03/30/91)

The following is a DEC VT52 terminal emulator for the HP48SX.  It emulates
every vt52 command except for the Keypad mode (kind of redundant on the HP)
and the special graphics characters (perhaps in a latter version).  The one
drawback, like other communication programs for the HP48, is speed.  Because
it is slow after the recieve buffer (which is 256 characters long) fills up,
it looses the rest.  Buffering the recieve buffer will not work since at
9600 baud the buffer fills up in about 3 hundredths of a second.  Nevertheless
Since fewer than 256 characters can fit on the screen at one time, it is
functional.  If enough interest shows, an assembly version could be written.
Another possibility is to set the IOPAR to enable XON/XOFF.  So far I have
not been able to get this to work.

Directions
1.  execute the program
2.  if you wish to do a file transfer, quit and do the usual Kermit transfer,
    then just run the program again to continue.

Keyboard

The keyboard of the HP48 was redefined as the following.

	1	2	3	4	5	6

	A	B	C	D	E	F
1	a	b	c	d	e	f
	^A	^B	^C	^D	^E	^F

	G	H	I	J	K	L
2	g	h	i	j	k	l
	^G	^H	^I	^J	^K	^L

	M	N	O	P	Q	R
3	m	n	o	p	q	r
	^M	^N	^O	^P	^Q	^R

	S	T	U	V	W	X
4	s	t	u	v	w	x
	^S	^T	^U	^V	^W	^X

	ENTER	Y	Z
5	ENTER	y	z	DELETE	BACKSPACE
	ENTER	^Y	^Z

		{	<	(	[
6	ESCAPE	7	8	9	/
	\	}	>	)	]

	CAPS LOCK	$	%	^	&
7	SHIFT	4	5	6	*
	QUIT	CHR(28)	CHR(29)	CHR(30)	CHR(31)

		,	~	`	'
8	CONTROL	1	2	3	-
	BREAK	;	@	#	"

		=	?	_	|
9	ATTENTION	0	.	SPACE	+
		CHR(0)	!	TAB	:

The labels above the numbered row is the left shift key.  Labels on the
same line as the numbers are the default values and labels under the
numbered lines are the right shift values.
The numbers are the row and column of the keyboard.  Quitting by pressing ON
leaves the port open and is not necessary even to stay online.
All 128 ASCII characters are accessible from the keyboard.  I suggest getting
a template and writing the above table on it for easiest use.

Send suggestions, comments, complains to:

_______________________________________________________________________________
Dave Jansen             |  INTERNET:  eldorado@en.ecn.purdue.edu
Electrical Engineering  |  BITNET:    eldorado%ea.ecn.purdue.edu@purccvm
Purdue University       |  UUCP:     {purdue, pur-ee}!en.ecn.purdue.edu!eldorado

Cut here 8<--------------------------------------------------------------------
%%HP: T(3)A(D)F(.);
\<< # 0d # 0d "" ""
"" "" \-> col row cur
spc char keymap
  \<<
    \<< 51 13 146 13
241 13 54 127 55 8
284 9 275 34 282 0
201 1 202 2 203 3
204 4 205 5 206 6
211 7 212 8 213 9
214 10 215 11 216
12 221 13 222 14
223 15 224 16 225
17 226 18 231 19
232 20 233 21 234
22 235 23 236 24
242 25 243 26 61 27
262 28 263 29 264
30 265 31
"..........abcdef....ghijkl....mnopqr....stuvwx.....yz........789/......456*......123-......0. +..........ABCDEF....GHIJKL....MNOPQR....STUVWX.....YZ........{<([......$%^&......,~`'......=?_|..........ABCDEF....GHIJKL....MNOPQR....STUVWX.....YZ.......\\}>)]................;@#........!.:"
1 39
      START ROT ROT
CHR REPL
      NEXT 'keymap'
STO
    \>>
    \<< PICT col row
2 \->LIST DUP2 col
# 5d + row # 7d + 2
\->LIST SUB 'char'
STO cur REPL
    \>>
    \<< PICT col row
2 \->LIST char REPL
      IF row # 56d
<
      THEN # 8d
'row' STO+
      ELSE PICT DUP
{ # 0d # 0d } OVER
{ # 0d # 8d } {
# 131d # 63d } SUB
REPL { # 0d # 56d }
# 131d # 8d BLANK
REPL
      END PICT col
row 2 \->LIST DUP2
col # 5d + row # 7d
+ 2 \->LIST SUB
'char' STO cur REPL
    \>> \-> addcntrl
get nl
    \<<
      \<< 2 \->GROB
PICT col row 2
\->LIST ROT REPL
'col' STO+
        IF col
# 131d >
        THEN # 0d
'col' STO get EVAL
nl EVAL
        ELSE get
EVAL
        END
      \>>
      \<< DROP
        WHILE
BUFLEN DROP NOT
        REPEAT
        END 1 SRECV
DROP NUM
        CASE DUP 65
==
          THEN PICT
col row 2 \->LIST
char REPL
            IF row
# 7d >
            THEN
'row' # 8d STO-
            END get
EVAL
          END DUP
66 ==
          THEN PICT
col row 2 \->LIST
char REPL
            IF row
# 56d <
            THEN
# 8d 'row' STO+
            END get
EVAL
          END DUP
67 ==
          THEN PICT
col row 2 \->LIST
char REPL
            IF col
# 125d <
            THEN
# 6d 'col' STO+
            END get
EVAL
          END DUP
68 ==
          THEN PICT
col row 2 \->LIST
char REPL
            IF col
# 5d >
            THEN
'col' # 6d STO-
            END get
EVAL
          END DUP
72 ==
          THEN PICT
col row 2 \->LIST
char REPL # 0d
'col' STO # 0d
'row' STO get EVAL
          END DUP
73 ==
          THEN PICT
col row 2 \->LIST
char REPL
            IF row
# 7d >
            THEN
'row' # 8d STO-
            ELSE
PICT DUP { # 0d
# 8d } OVER { # 0d
# 0d } { # 131d
# 55d } SUB REPL {
# 0d # 0d } # 131d
# 8d BLANK REPL
            END get
EVAL
          END DUP
74 ==
          THEN PICT
# 0d row 2 \->LIST
# 131d # 64d row -
BLANK REPL get EVAL
          END DUP
75 ==
          THEN PICT
col row 2 \->LIST
# 131d col - # 8d
BLANK REPL get EVAL
          END DUP
89 ==
          THEN PICT
col row 2 \->LIST
char REPL
            WHILE
BUFLEN DROP NOT
            REPEAT
            END 1
SRECV DROP NUM 32 -
# 8d * 'row' STO
            WHILE
BUFLEN DROP NOT
            REPEAT
            END 1
SRECV DROP NUM 32 -
# 6d * 'col' STO
get EVAL
          END DUP
90 ==
          THEN 27
CHR "/Z" + XMIT
DROP
          END
        END DROP
      \>>
      \<<
        CASE DUP
127 ==
          THEN PICT
col row 2 \->LIST spc
REPL
            IF col
# 5d >
            THEN
'col' # 6d STO-
            ELSE
# 126d 'col' STO
'row' # 8d STO-
            END
PICT col row 2
\->LIST cur REPL
          END DUP
13 ==
          THEN PICT
col row 2 \->LIST
char REPL # 0d
'col' STO get EVAL
          END DUP
DUP 10 \>= SWAP 12 \<=
AND
          THEN nl
EVAL
          END DUP 8
==
          THEN PICT
col row 2 \->LIST
char REPL
            IF col
# 5d >
            THEN
'col' # 6d STO-
            ELSE
# 126d 'col' STO
              IF
row # 7d >
              THEN
'row' # 8d STO-
              ELSE
PICT DUP { # 0d
# 8d } OVER { # 0d
# 0d } { # 131d
# 55d } SUB REPL {
# 0d # 0d } # 131d
# 8d BLANK REPL
              END
            END get
EVAL
          END DUP 7
==
          THEN 440
.1 BEEP
          END DUP 9
==
          THEN PICT
col row 2 \->LIST
char REPL col # 12d
/ # 1d + # 12d *
            IF DUP
# 131d >
            THEN
DROP # 0d 'col' STO
get EVAL nl EVAL
            ELSE
'col' STO get EVAL
            END
          END
        END DROP
      \>> 0 { } \->
write vt52 cntrl
room flags
      \<< RCLF
'flags' STO
addcntrl EVAL 127
CHR 2 \->GROB 'cur'
STO 32 CHR 2 \->GROB
DUP 'spc' STO
'char' STO -40 CF
OPENIO ERASE PICT {
# 0d # 0d } DUP
PVIEW # 0d 'col'
STO # 0d 'row' STO
cur REPL 7 CF 8 CF
9 CF 10 SF
        WHILE 10
FS?
        REPEAT
          IF BUFLEN
DROP
          THEN
# 131d col - # 6d /
B\->R 'room' STO ""
            DO 1
SRECV DROP DUP NUM
              IF
DUP 31 > SWAP 127 <
AND
              THEN
+
              ELSE
9 SF SWAP
              END
            UNTIL
DUP SIZE room > 9
FS? OR BUFLEN DROP
NOT OR
            END
            IF DUP
SIZE DUP
            THEN
# 6d * SWAP write
EVAL
            ELSE
DROP2
            END
            IF 9
FS?C
            THEN
              IF
NUM DUP 27 ==
              THEN
vt52 EVAL
              ELSE
cntrl EVAL
              END
            END
          END
          IF KEY
          THEN
            IF DUP
DUP DUP2 10 > SWAP
54 < AND SWAP 51 \=/
AND 6 FS? AND 8 FC?
AND 7 FS? OR SWAP
71 \=/ AND
            THEN 95
+ 7 CF
            ELSE
              IF
DUP DUP 71 \=/ SWAP
81 \=/ AND 8 FS? AND
              THEN
190 + 8 CF
              END
            END
            IF DUP
71 ==
            THEN
              IF 8
FS?C
              THEN
10 CF
              ELSE
IF 7 FS?C
THEN
  IF 6 DUP FS?
  THEN CF
  ELSE SF
  END
ELSE 7 SF
END
              END
DROP
            ELSE
              IF
DUP 81 ==
              THEN
IF 8 FS?C
THEN SBRK
ELSE 8 SF
END DROP
              ELSE
keymap SWAP DUP SUB
XMIT DROP
              END
            END
          END
        END CLOSEIO
TEXT flags STOF
      \>>
    \>>
  \>>
\>>
-- 

P.O.W. * M.I.A.  --  You are not forgotten
_______________________________________________________________________________
Dave Jansen             |  INTERNET:  eldorado@en.ecn.purdue.edu