1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 (%include e-macros)
20
21 (declare (special X Y screenheight screenlinelen ospeed))
22 (declare (special idel-lines-availablep idel-chars-availablep tty-type))
23 (declare (special DCTL-prologue-availablep DCTL-epilogue-availablep))
24 (declare (special region-scroll-availablep))
25 (declare (*expr Rprinc Rtyo))
26
27
28 (defun tdv2220-escape ()
29 (Rtyo 33) (Rprinc "["))
30
31
32 (defun DCTL-outdec (n)
33 ((lambda (have-output)
34 (do digi '(1000. 100. 10. 1) (cdr digi) (null digi)
35 ((lambda (rem)
36 (cond ((or have-output (> rem 0) (= (car digi) 1))
37 (Rtyo (+ 60 rem))
38 (setq have-output t)))
39 (setq n (\ n (car digi))))
40 (// n (car digi)))))
41 nil))
42
43
44
45 (defun DCTL-pad (n)
46 (do-times (// (* n ospeed) 960.)
47 (Rtyo 0)))
48
49
50
51 (defun DCTL-init ()
52 (setq DCTL-prologue-availablep t DCTL-epilogue-availablep t)
53 (setq idel-lines-availablep t idel-chars-availablep t)
54 (setq region-scroll-availablep nil)
55 (setq screenheight 24. screenlinelen 79.)
56 (setq tty-type 'tdv2220)
57 (DCTL-prologue)
58 (DCTL-home-cursor)
59 (DCTL-clear-rest-of-screen))
60
61
62 (defun DCTL-prologue ()
63 (tdv2220-escape) (Rprinc "36l"))
64
65
66
67 (defun DCTL-epilogue ()
68 (tdv2220-escape) (Rprinc "36h"))
69
70
71
72 (defun DCTL-position-cursor (x y)
73 (let ((deltax (- x X))
74 (deltay (- y Y)))
75 (cond ((= deltay 0)
76 (cond ((= deltax 0) nil)
77 ((> deltax 0) (tdv2220-escape) (DCTL-outdec deltax)
78 (Rprinc "C"))
79 ((= x 0) (Rtyo 15))
80 (t (tdv2220-escape) (DCTL-outdec (- deltax)) (Rprinc "D"))))
81 ((= deltax 0)
82 (cond ((> deltay 0) (tdv2220-escape) (DCTL-outdec deltay)
83 (Rprinc "B"))
84 (t (tdv2220-escape) (DCTL-outdec (- deltay)) (Rprinc "A"))))
85 (t (tdv2220-absolute-position x y)))
86 (setq X x Y y)))
87
88
89
90 (defun tdv2220-absolute-position (x y)
91 (tdv2220-escape)
92 (DCTL-outdec (1+ y))
93 (Rprinc ";")
94 (DCTL-outdec (1+ x))
95 (Rprinc "H"))
96
97
98
99 (defun DCTL-display-char-string (string)
100 (setq X (+ X (stringlength string)))
101 (Rprinc string))
102
103
104
105 (defun DCTL-home-cursor ()
106 (setq X 0 Y 0)
107 (tdv2220-escape) (Rprinc "H"))
108
109
110
111 (defun DCTL-clear-rest-of-screen ()
112 (tdv2220-escape) (Rprinc "J"))
113
114
115
116 (defun DCTL-kill-line ()
117 (tdv2220-escape) (Rprinc "K"))
118
119
120
121 (defun DCTL-insert-lines (n)
122 (tdv2220-escape) (DCTL-outdec n) (Rprinc "L")
123 (DCTL-pad (* n 10.)))
124
125
126
127 (defun DCTL-delete-lines (n)
128 (tdv2220-escape) (DCTL-outdec n) (Rprinc "M")
129 (DCTL-pad (* n 10.)))
130
131
132
133 (defun DCTL-insert-char-string (string)
134 (tdv2220-escape) (DCTL-outdec (stringlength string))
135 (Rprinc "@")
136 (DCTL-display-char-string string))
137
138 (defun DCTL-delete-chars (n)
139 (tdv2220-escape) (DCTL-outdec n)
140 (Rprinc "P"))