1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 (declare (special X Y screenheight tty-type ospeed))
20 (declare (special screenlinelen))
21 (declare (special idel-chars-availablep idel-lines-availablep tty-no-cleolp))
22
23
24 (defun DCTL-init ()
25 (setq screenheight 24.)
26 (setq screenlinelen 79.)
27 (setq tty-type 'vis200)
28 (setq idel-lines-availablep t idel-chars-availablep t tty-no-cleolp nil)
29 (Rtyo 27.) (Rprinc "v")
30 (setq X 0 Y 0))
31
32
33
34 (defun DCTL-position-cursor (x y)
35 (prog (ycost
36 xcost
37 what
38 cost)
39 (and (= x X)(= y Y)
40 (return nil))
41 (setq what 1
42 cost (+ 2 y x x))
43 (and (> cost 4)
44 (setq what 0
45 cost 4))
46 (setq ycost (cond ((< y Y) (- Y y))
47 (t (lsh (- y Y) 1))))
48 (setq xcost (cond ((> x X) (- x X))
49 (t (lsh (- X x) 1))))
50 (and (< (+ ycost xcost) cost)
51 (setq what 3
52 cost (+ ycost xcost)))
53 (and (< (+ 1 ycost x) cost)
54 (setq what 2))
55 (cond ((= what 0)
56
57
58
59 (Rtyo 27.)
60 (Rprinc "Y")
61 (Rtyo (+ 40 y))
62 (Rtyo (+ 40 x))
63 (setq X x Y y)
64 (return nil))
65
66 ((= what 1)
67 (Rtyo 27.) (Rprinc "H")
68 (setq X 0 Y 0))
69
70
71 ((= what 2)
72 (Rtyo 15)
73 (setq X 0)))
74
75
76
77
78 (cond ((< X x)
79 (do ex X (1+ ex)(= ex x)(Rtyo 27.)(Rprinc "C")))
80 ((< x X)
81 (do ex x (1+ ex)(= ex X)(Rtyo 10))))
82 (cond ((< Y y)
83 (do wy Y (1+ wy)(= wy y)(Rtyo 12)))
84 ((< y Y)
85 (do wy y (1+ wy)(= wy Y)(Rtyo 27.)(Rprinc "A"))))
86 (setq X x Y y)
87 (return nil)))
88
89
90
91 (defun DCTL-display-char-string (string)
92 (setq X (+ X (stringlength string)))
93 (Rprinc string))
94
95
96
97 (defun DCTL-clear-rest-of-screen ()
98 (Rtyo 27.)(Rprinc "y")(setq X 0 Y 0))
99
100
101 (defun DCTL-insert-char-string (str)
102 (Rtyo 27.)(Rprinc "i")
103 (Rprinc str)
104 (Rtyo 27.)(Rprinc "j")
105 (setq X (+ X (stringlength str))))
106
107
108 (defun DCTL-delete-chars (n)
109 (do i 1 (1+ i) (> i n)
110 (Rtyo 27.)(Rprinc "O")))
111
112
113 (defun DCTL-insert-lines (n)
114 (do i 1 (1+ i)(> i n)
115 (Rtyo 27.)(Rprinc "L")))
116
117
118 (defun DCTL-delete-lines (n)
119 (do i 1 (1+ i)(> i n)
120 (Rtyo 33)(Rprinc "M")))
121
122
123 (defun DCTL-pad (n)
124 (do i (// (* n ospeed) 100000.) (1- i) (= i 0) (Rtyo 0)))
125
126 (defun DCTL-kill-line()
127 (Rtyo 27.)(Rprinc "x"))