summaryrefslogtreecommitdiff
path: root/app/mpg/1987/src/PICPLOT.ELA
blob: d8bf5a5b4a744372564dc24c896ddd1faa708c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
PACKET pic plot DEFINES drawing area,               {Autor: H. Indenbirken}
                        begin plot,                 {Stand: 13.02.85      }
                        end plot, 
                        clear, 
                        pen,
                        move, 
                        draw, 
                        get cursor,

                        get screen, put screen: 
 
LET hor faktor   = 22.21739,                   {***** x pixel / x cm *****}
    vert faktor  = 18.61314,                   {***** y pixel / y cm *****}

    h max  = 639,
    v max  = 287,

    delete = 0,                                {Farbcodes}
    std    = 1,
    black  = 5,
    white  = 6,
 
    nothing          = 0,                      {Linientypen}
    durchgehend      = 1, 
    gepunktet        = 2,
    kurz gestrichelt = 3,
    lang gestrichelt = 4,
    strichpunkt      = 5;

INT CONST move code :: -255,                   {Controlcodes}
          draw code :: -254,
          plot code :: -253,
          norm code :: -252,
          del  code :: -251,
          xor  code :: -250,
          line code :: -249;

LET POS = STRUCT (INT x, y);

INT VAR pen thick :: 0, pen code :: draw code, ack;
POS VAR pos :: POS : (0, 0);

PROC drawing area (REAL VAR x cm, y cm, INT VAR x pixel, y pixel) : 
   x cm    := 23.0;      y cm    := 13.7; 
   x pixel := h max;     y pixel := v max
END PROC drawing area;

PROC begin plot : 
  control (plot code, 0, 0, ack);
  out (""15"")
ENDPROC begin plot ;
 
PROC end plot : 
  out (""14"");
  control (norm code, 0, 0, ack)
ENDPROC end plot ;

PROC clear :
  pos := POS : (0, 0);
  pen (0, 1, 0, 1);
  page
END PROC clear;

PROC pen (INT CONST background, foreground, thickness, linetype):
  pen code := foreground colour;
  pen thick := thickness;
  control (line code, 0, 0, ack)  .

foreground colour:
  IF linetype = nothing
  THEN move code
  ELIF foreground = delete OR foreground = black
  THEN del code
  ELIF foreground < 0
  THEN xor code
  ELSE draw code FI  .
 
END PROC pen;

PROC move (INT CONST x, y) :
  control (move code, x, y);
  pos := POS  : (x, y)
END PROC move;
 
PROC draw (INT CONST x, y) :
  control (pen code, x, y);
  IF thick line
  THEN IF horizontal line
       THEN thick y
       ELSE thick x FI;
       control (move code, x, y)
  FI;
  pos := POS : (x, y)   .

thick line:
  pen thick > 0 AND pen code <> move code  .

horizontal line:
  abs (pos.x-x) > abs (pos.y-y)  .

thick y:
  INT VAR dy;
  FOR dy FROM 1 UPTO pen thick
  REP control (move code, pos.x, pos.y+dy);
      control (pen code,      x,     y+dy); 
      control (move code, pos.x, pos.y-dy);
      control (pen code,      x,     y-dy)
  PER  . 

thick x:
  INT VAR dx;
  FOR dx FROM 1 UPTO pen thick
  REP control (move code, pos.x+dx, pos.y);
      control (pen code,      x+dx,     y); 
      control (move code, pos.x-dx, pos.y);
      control (pen code,      x-dx,     y)
  PER  . 

END PROC draw;
 
PROC draw (TEXT CONST record) :
  draw (record, 0.0, 0.0, 0.0)
END PROC draw;

PROC draw (TEXT CONST record, REAL CONST angle, height, width):
  IF pen code = draw code
  THEN cursor (x position, y position);
       out (record)
  FI  .

x position:
  (pos.x-1) DIV 8 + 1  .

y position:
  (pos.y-1) DIV 12 + 1  .

END PROC draw;

PROC control (INT CONST code, x, y):
  control (code, x check, y check, ack)  .

x check:
  IF x < 0
  THEN 0
  ELIF x > h max
  THEN h max
  ELSE x FI  . 

y check:
  IF y =< 0
  THEN v max
  ELIF y >= v max
  THEN 0
  ELSE v max-y FI  .

END PROC control;
 
PROC get cursor (TEXT VAR t, INT VAR x, y) :
  get cursor (t, x, y, -1, -1, -1, -1)
END PROC get cursor;

PROC get cursor (TEXT VAR t, INT VAR x, y, INT CONST x0, y0, x1, y1):
  check;
  init cursor;
  REP set cursor;
      get step;
      set cursor;
      move cursor
  PER  .

init cursor:
  INT VAR delta := 1;
  x := pos.x;
  y := pos.y  .

set cursor:
  IF x0 > 0 AND y0 > 0
  THEN control (move code, x0, v max-y0, ack);
       control (xor  code, x, v max-y, ack)
  FI;
  IF x1 > 0 AND y1 > 0
  THEN control (move code, x1, v max-y1, ack);
       control (xor  code, x, v max-y, ack)
  FI;
  control (move code, x-4, v max-y, ack);
  control (xor  code, x+5, v max-y, ack);
  control (move code, x, v max-y-4, ack);
  control (xor  code, x, v max-y-4, ack)  .

get step:
  t := incharety (1);
  IF t <> ""
  THEN IF delta < 10
       THEN delta INCR delta
       ELSE delta INCR 1 FI
  ELSE delta := 1;
       inchar (t)
  FI  .

move cursor:
  SELECT code (t) OF
  CASE 2 : x INCR delta
  CASE 3 : y INCR delta
  CASE 8 : x DECR delta
  CASE 10: y DECR delta
  OTHERWISE leave get cursor ENDSELECT;
  check  .

leave get cursor:
  control (move code, pos.x, pos.y);
  LEAVE get cursor  .

check :
  IF x < 0
  THEN x := 0; out (""7"")
  ELIF x > h max
  THEN x := h max; out (""7"") FI; 

  IF y < 0
  THEN y := 0; out (""7"")
  ELIF y > v max
  THEN y := v max; out (""7"") FI  .

END PROC get cursor;

(* Bildwiederholspeicheraufbau des Pic 400:                              *)
(* 45 Bl”cke (0...44) enthalten den Bildwiederholspeicher.               *)

PROC get screen (DATASPACE VAR ds, INT CONST page):
  INT VAR i, n, begin :: 45*page;
  FOR i FROM 0 UPTO 44
  REP block in (ds, begin+i, -1, i, n) PER
END PROC get screen;

PROC put screen (DATASPACE CONST ds, INT CONST page):
  INT VAR i, n, begin :: 45*page;
  FOR i FROM 0 UPTO 44
  REP block out (ds, begin+i, -1, i, n) PER
END PROC put screen;

END PACKET pic plot;