1 /* voc 2.1.0 [2019/11/01]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */
2
3 #define SHORTINT INT8
4 #define INTEGER INT16
5 #define LONGINT INT32
6 #define SET UINT32
7
8 #include "SYSTEM.h"
9 #include "Files.h"
10 #include "Modules.h"
11 #include "Out.h"
12 #include "Reals.h"
13
14 typedef
15 struct Texts_RunDesc *Texts_Run;
16
17 typedef
18 struct Texts_FontDesc *Texts_FontsFont;
19
20 typedef
21 struct Texts_RunDesc {
22 Texts_Run prev, next;
23 INT32 len;
24 Texts_FontsFont fnt;
25 INT8 col, voff;
26 BOOLEAN ascii;
27 } Texts_RunDesc;
28
29 typedef
30 struct Texts_ElemDesc *Texts_Elem;
31
32 typedef
33 struct Texts_ElemMsg {
34 char _prvt0[1];
35 } Texts_ElemMsg;
36
37 typedef
38 void (*Texts_Handler)(Texts_Elem, Texts_ElemMsg*, ADDRESS *);
39
40 typedef
41 struct Texts_TextDesc *Texts_Text;
42
43 typedef
44 struct Texts_ElemDesc {
45 Texts_Run prev, next;
46 INT32 len;
47 Texts_FontsFont fnt;
48 INT8 col, voff;
49 BOOLEAN ascii;
50 INT32 W, H;
51 Texts_Handler handle;
52 Texts_Text base;
53 } Texts_ElemDesc;
54
55 struct Texts__1 { /* Texts_ElemDesc */
56 Texts_Run prev, next;
57 INT32 len;
58 Texts_FontsFont fnt;
59 INT8 col, voff;
60 BOOLEAN ascii;
61 INT32 W, H;
62 Texts_Handler handle;
63 Texts_Text base;
64 Files_File file;
65 INT32 org, span;
66 CHAR mod[32], proc[32];
67 };
68
69 typedef
70 struct Texts__1 *Texts_Alien;
71
72 typedef
73 struct Texts_BufDesc {
74 INT32 len;
75 Texts_Run head;
76 } Texts_BufDesc;
77
78 typedef
79 Texts_BufDesc *Texts_Buffer;
80
81 typedef
82 struct Texts_CopyMsg { /* Texts_ElemMsg */
83 Texts_Elem e;
84 } Texts_CopyMsg;
85
86 typedef
87 struct Texts_FileMsg { /* Texts_ElemMsg */
88 INT16 id;
89 INT32 pos;
90 Files_Rider r;
91 } Texts_FileMsg;
92
93 typedef
94 struct Texts_FontDesc {
95 CHAR name[32];
96 } Texts_FontDesc;
97
98 typedef
99 struct Texts_IdentifyMsg { /* Texts_ElemMsg */
100 CHAR mod[32], proc[32];
101 } Texts_IdentifyMsg;
102
103 typedef
104 void (*Texts_Notifier)(Texts_Text, INT16, INT32, INT32);
105
106 typedef
107 struct Texts_PieceDesc *Texts_Piece;
108
109 typedef
110 struct Texts_PieceDesc {
111 Texts_Run prev, next;
112 INT32 len;
113 Texts_FontsFont fnt;
114 INT8 col, voff;
115 BOOLEAN ascii;
116 Files_File file;
117 INT32 org;
118 } Texts_PieceDesc;
119
120 typedef
121 struct Texts_Reader {
122 BOOLEAN eot;
123 Texts_FontsFont fnt;
124 INT8 col, voff;
125 Texts_Elem elem;
126 Files_Rider rider;
127 Texts_Run run;
128 INT32 org, off;
129 } Texts_Reader;
130
131 typedef
132 struct Texts_Scanner { /* Texts_Reader */
133 BOOLEAN eot;
134 Texts_FontsFont fnt;
135 INT8 col, voff;
136 Texts_Elem elem;
137 Files_Rider rider;
138 Texts_Run run;
139 INT32 org, off;
140 CHAR nextCh;
141 INT16 line, class;
142 INT32 i;
143 REAL x;
144 LONGREAL y;
145 CHAR c;
146 INT8 len;
147 CHAR s[64];
148 } Texts_Scanner;
149
150 typedef
151 struct Texts_TextDesc {
152 INT32 len;
153 Texts_Notifier notify;
154 Texts_Run head, cache;
155 INT32 corg;
156 } Texts_TextDesc;
157
158 typedef
159 struct Texts_Writer {
160 Texts_Buffer buf;
161 Texts_FontsFont fnt;
162 INT8 col, voff;
163 Files_Rider rider;
164 Files_File file;
165 } Texts_Writer;
166
167
168 export Texts_Elem Texts_new;
169 static Texts_Buffer Texts_del;
170 static Texts_FontsFont Texts_FontsDefault;
171
172 export ADDRESS *Texts_FontDesc__typ;
173 export ADDRESS *Texts_RunDesc__typ;
174 export ADDRESS *Texts_PieceDesc__typ;
175 export ADDRESS *Texts_ElemMsg__typ;
176 export ADDRESS *Texts_ElemDesc__typ;
177 export ADDRESS *Texts_FileMsg__typ;
178 export ADDRESS *Texts_CopyMsg__typ;
179 export ADDRESS *Texts_IdentifyMsg__typ;
180 export ADDRESS *Texts_BufDesc__typ;
181 export ADDRESS *Texts_TextDesc__typ;
182 export ADDRESS *Texts_Reader__typ;
183 export ADDRESS *Texts_Scanner__typ;
184 export ADDRESS *Texts_Writer__typ;
185 export ADDRESS *Texts__1__typ;
186
187 export void Texts_Append (Texts_Text T, Texts_Buffer B);
188 export void Texts_ChangeLooks (Texts_Text T, INT32 beg, INT32 end, UINT32 sel, Texts_FontsFont fnt, INT8 col, INT8 voff);
189 static Texts_Elem Texts_CloneElem (Texts_Elem e);
190 static Texts_Piece Texts_ClonePiece (Texts_Piece p);
191 export void Texts_Close (Texts_Text T, CHAR *name, ADDRESS name__len);
192 export void Texts_Copy (Texts_Buffer SB, Texts_Buffer DB);
193 export void Texts_CopyElem (Texts_Elem SE, Texts_Elem DE);
194 export void Texts_Delete (Texts_Text T, INT32 beg, INT32 end);
195 export Texts_Text Texts_ElemBase (Texts_Elem E);
196 export INT32 Texts_ElemPos (Texts_Elem E);
197 static void Texts_Find (Texts_Text T, INT32 *pos, Texts_Run *u, INT32 *org, INT32 *off);
198 static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len);
199 static void Texts_HandleAlien (Texts_Elem E, Texts_ElemMsg *msg, ADDRESS *msg__typ);
200 export void Texts_Insert (Texts_Text T, INT32 pos, Texts_Buffer B);
201 export void Texts_Load (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
202 static void Texts_Load0 (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
203 static void Texts_Merge (Texts_Text T, Texts_Run u, Texts_Run *v);
204 export void Texts_Open (Texts_Text T, CHAR *name, ADDRESS name__len);
205 export void Texts_OpenBuf (Texts_Buffer B);
206 export void Texts_OpenReader (Texts_Reader *R, ADDRESS *R__typ, Texts_Text T, INT32 pos);
207 export void Texts_OpenScanner (Texts_Scanner *S, ADDRESS *S__typ, Texts_Text T, INT32 pos);
208 export void Texts_OpenWriter (Texts_Writer *W, ADDRESS *W__typ);
209 export INT32 Texts_Pos (Texts_Reader *R, ADDRESS *R__typ);
210 export void Texts_Read (Texts_Reader *R, ADDRESS *R__typ, CHAR *ch);
211 export void Texts_ReadElem (Texts_Reader *R, ADDRESS *R__typ);
212 export void Texts_ReadPrevElem (Texts_Reader *R, ADDRESS *R__typ);
213 export void Texts_Recall (Texts_Buffer *B);
214 export void Texts_Save (Texts_Text T, INT32 beg, INT32 end, Texts_Buffer B);
215 export void Texts_Scan (Texts_Scanner *S, ADDRESS *S__typ);
216 export void Texts_SetColor (Texts_Writer *W, ADDRESS *W__typ, INT8 col);
217 export void Texts_SetFont (Texts_Writer *W, ADDRESS *W__typ, Texts_FontsFont fnt);
218 export void Texts_SetOffset (Texts_Writer *W, ADDRESS *W__typ, INT8 voff);
219 static void Texts_Splice (Texts_Run un, Texts_Run v, Texts_Run w, Texts_Text base);
220 static void Texts_Split (INT32 off, Texts_Run *u, Texts_Run *un);
221 export void Texts_Store (Files_Rider *r, ADDRESS *r__typ, Texts_Text T);
222 export void Texts_Write (Texts_Writer *W, ADDRESS *W__typ, CHAR ch);
223 export void Texts_WriteDate (Texts_Writer *W, ADDRESS *W__typ, INT32 t, INT32 d);
224 export void Texts_WriteElem (Texts_Writer *W, ADDRESS *W__typ, Texts_Elem e);
225 export void Texts_WriteHex (Texts_Writer *W, ADDRESS *W__typ, INT32 x);
226 export void Texts_WriteInt (Texts_Writer *W, ADDRESS *W__typ, INT64 x, INT64 n);
227 export void Texts_WriteLn (Texts_Writer *W, ADDRESS *W__typ);
228 export void Texts_WriteLongReal (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x, INT16 n);
229 export void Texts_WriteLongRealHex (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x);
230 export void Texts_WriteReal (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n);
231 export void Texts_WriteRealFix (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n, INT16 k);
232 export void Texts_WriteRealHex (Texts_Writer *W, ADDRESS *W__typ, REAL x);
233 export void Texts_WriteString (Texts_Writer *W, ADDRESS *W__typ, CHAR *s, ADDRESS s__len);
234
235
Texts_FontsThis(CHAR * name,ADDRESS name__len)236 static Texts_FontsFont Texts_FontsThis (CHAR *name, ADDRESS name__len)
237 {
238 Texts_FontsFont F = NIL;
239 __NEW(F, Texts_FontDesc);
240 __COPY(name, F->name, 32);
241 return F;
242 }
243
Texts_Find(Texts_Text T,INT32 * pos,Texts_Run * u,INT32 * org,INT32 * off)244 static void Texts_Find (Texts_Text T, INT32 *pos, Texts_Run *u, INT32 *org, INT32 *off)
245 {
246 Texts_Run v = NIL;
247 INT32 m;
248 if (*pos >= T->len) {
249 *pos = T->len;
250 *u = T->head;
251 *org = T->len;
252 *off = 0;
253 T->cache = T->head;
254 T->corg = 0;
255 } else {
256 v = T->cache->next;
257 m = *pos - T->corg;
258 if (*pos >= T->corg) {
259 while (m >= v->len) {
260 m -= v->len;
261 v = v->next;
262 }
263 } else {
264 while (m < 0) {
265 v = v->prev;
266 m += v->len;
267 }
268 }
269 *u = v;
270 *org = *pos - m;
271 *off = m;
272 T->cache = v->prev;
273 T->corg = *org;
274 }
275 }
276
Texts_Split(INT32 off,Texts_Run * u,Texts_Run * un)277 static void Texts_Split (INT32 off, Texts_Run *u, Texts_Run *un)
278 {
279 Texts_Piece p = NIL, U = NIL;
280 if (off == 0) {
281 *un = *u;
282 *u = (*un)->prev;
283 } else if (off >= (*u)->len) {
284 *un = (*u)->next;
285 } else {
286 __NEW(p, Texts_PieceDesc);
287 *un = (Texts_Run)p;
288 U = __GUARDP(*u, Texts_PieceDesc, 1);
289 __GUARDEQP(p, Texts_PieceDesc) = *U;
290 p->org += off;
291 p->len -= off;
292 U->len -= p->len;
293 p->ascii = (*u)->ascii;
294 p->prev = (Texts_Run)U;
295 p->next = U->next;
296 p->next->prev = (Texts_Run)p;
297 U->next = (Texts_Run)p;
298 }
299 }
300
Texts_Merge(Texts_Text T,Texts_Run u,Texts_Run * v)301 static void Texts_Merge (Texts_Text T, Texts_Run u, Texts_Run *v)
302 {
303 Texts_Piece p = NIL, q = NIL;
304 if ((((((((((__ISP(u, Texts_PieceDesc, 1) && __ISP(*v, Texts_PieceDesc, 1))) && __STRCMP(u->fnt->name, (*v)->fnt->name) == 0)) && u->col == (*v)->col)) && u->voff == (*v)->voff)) && __GUARDP(u, Texts_PieceDesc, 1)->ascii == __GUARDP(*v, Texts_PieceDesc, 1)->ascii)) {
305 p = __GUARDP(u, Texts_PieceDesc, 1);
306 q = __GUARDP(*v, Texts_PieceDesc, 1);
307 if ((p->file == q->file && p->org + p->len == q->org)) {
308 if (T->cache == u) {
309 T->corg += q->len;
310 } else if (T->cache == *v) {
311 T->cache = T->head;
312 T->corg = 0;
313 }
314 p->len += q->len;
315 *v = (*v)->next;
316 }
317 }
318 }
319
Texts_Splice(Texts_Run un,Texts_Run v,Texts_Run w,Texts_Text base)320 static void Texts_Splice (Texts_Run un, Texts_Run v, Texts_Run w, Texts_Text base)
321 {
322 Texts_Run u = NIL;
323 if (v != w->next) {
324 u = un->prev;
325 u->next = v;
326 v->prev = u;
327 un->prev = w;
328 w->next = un;
329 do {
330 if (__ISP(v, Texts_ElemDesc, 1)) {
331 __GUARDP(v, Texts_ElemDesc, 1)->base = base;
332 }
333 v = v->next;
334 } while (!(v == un));
335 }
336 }
337
Texts_ClonePiece(Texts_Piece p)338 static Texts_Piece Texts_ClonePiece (Texts_Piece p)
339 {
340 Texts_Piece q = NIL;
341 __NEW(q, Texts_PieceDesc);
342 __GUARDEQP(q, Texts_PieceDesc) = *p;
343 return q;
344 }
345
Texts_CloneElem(Texts_Elem e)346 static Texts_Elem Texts_CloneElem (Texts_Elem e)
347 {
348 Texts_CopyMsg msg;
349 msg.e = NIL;
350 (*e->handle)(e, (void*)&msg, Texts_CopyMsg__typ);
351 return msg.e;
352 }
353
Texts_CopyElem(Texts_Elem SE,Texts_Elem DE)354 void Texts_CopyElem (Texts_Elem SE, Texts_Elem DE)
355 {
356 DE->len = SE->len;
357 DE->fnt = SE->fnt;
358 DE->col = SE->col;
359 DE->voff = SE->voff;
360 DE->W = SE->W;
361 DE->H = SE->H;
362 DE->handle = SE->handle;
363 }
364
Texts_ElemBase(Texts_Elem E)365 Texts_Text Texts_ElemBase (Texts_Elem E)
366 {
367 return E->base;
368 }
369
Texts_ElemPos(Texts_Elem E)370 INT32 Texts_ElemPos (Texts_Elem E)
371 {
372 Texts_Run u = NIL;
373 INT32 pos;
374 u = E->base->head->next;
375 pos = 0;
376 while (u != (void *) E) {
377 pos = pos + u->len;
378 u = u->next;
379 }
380 return pos;
381 }
382
Texts_HandleAlien(Texts_Elem E,Texts_ElemMsg * msg,ADDRESS * msg__typ)383 static void Texts_HandleAlien (Texts_Elem E, Texts_ElemMsg *msg, ADDRESS *msg__typ)
384 {
385 Texts_Alien e = NIL;
386 Files_Rider r;
387 INT32 i;
388 CHAR ch;
389 if (__ISP(E, Texts__1, 2)) {
390 if (__IS(msg__typ, Texts_CopyMsg, 1)) {
391 if (__IS(msg__typ, Texts_CopyMsg, 1)) {
392 Texts_CopyMsg *msg__ = (void*)msg;
393 __NEW(e, Texts__1);
394 Texts_CopyElem((void*)(*(Texts_Alien*)&E), (void*)e);
395 e->file = (*(Texts_Alien*)&E)->file;
396 e->org = (*(Texts_Alien*)&E)->org;
397 e->span = (*(Texts_Alien*)&E)->span;
398 __MOVE((*(Texts_Alien*)&E)->mod, e->mod, 32);
399 __MOVE((*(Texts_Alien*)&E)->proc, e->proc, 32);
400 (*msg__).e = (Texts_Elem)e;
401 } else __WITHCHK;
402 } else if (__IS(msg__typ, Texts_IdentifyMsg, 1)) {
403 if (__IS(msg__typ, Texts_IdentifyMsg, 1)) {
404 Texts_IdentifyMsg *msg__ = (void*)msg;
405 __COPY((*(Texts_Alien*)&E)->mod, (*msg__).mod, 32);
406 __COPY((*(Texts_Alien*)&E)->proc, (*msg__).proc, 32);
407 (*msg__).mod[31] = 0x01;
408 } else __WITHCHK;
409 } else if (__IS(msg__typ, Texts_FileMsg, 1)) {
410 if (__IS(msg__typ, Texts_FileMsg, 1)) {
411 Texts_FileMsg *msg__ = (void*)msg;
412 if ((*msg__).id == 1) {
413 Files_Set(&r, Files_Rider__typ, (*(Texts_Alien*)&E)->file, (*(Texts_Alien*)&E)->org);
414 i = (*(Texts_Alien*)&E)->span;
415 while (i > 0) {
416 Files_Read(&r, Files_Rider__typ, (void*)&ch);
417 Files_Write(&(*msg__).r, Files_Rider__typ, ch);
418 i -= 1;
419 }
420 }
421 } else __WITHCHK;
422 }
423 } else __WITHCHK;
424 }
425
Texts_OpenBuf(Texts_Buffer B)426 void Texts_OpenBuf (Texts_Buffer B)
427 {
428 Texts_Run u = NIL;
429 __NEW(u, Texts_RunDesc);
430 u->next = u;
431 u->prev = u;
432 B->head = u;
433 B->len = 0;
434 }
435
Texts_Copy(Texts_Buffer SB,Texts_Buffer DB)436 void Texts_Copy (Texts_Buffer SB, Texts_Buffer DB)
437 {
438 Texts_Run u = NIL, v = NIL, vn = NIL;
439 u = SB->head->next;
440 v = DB->head->prev;
441 while (u != SB->head) {
442 if (__ISP(u, Texts_PieceDesc, 1)) {
443 vn = (Texts_Run)Texts_ClonePiece(__GUARDP(u, Texts_PieceDesc, 1));
444 } else {
445 vn = (Texts_Run)Texts_CloneElem(__GUARDP(u, Texts_ElemDesc, 1));
446 }
447 v->next = vn;
448 vn->prev = v;
449 v = vn;
450 u = u->next;
451 }
452 v->next = DB->head;
453 DB->head->prev = v;
454 DB->len += SB->len;
455 }
456
Texts_Recall(Texts_Buffer * B)457 void Texts_Recall (Texts_Buffer *B)
458 {
459 *B = Texts_del;
460 Texts_del = NIL;
461 }
462
Texts_Save(Texts_Text T,INT32 beg,INT32 end,Texts_Buffer B)463 void Texts_Save (Texts_Text T, INT32 beg, INT32 end, Texts_Buffer B)
464 {
465 Texts_Run u = NIL, v = NIL, w = NIL, wn = NIL;
466 INT32 uo, ud, vo, vd;
467 Texts_Find(T, &beg, &u, &uo, &ud);
468 Texts_Find(T, &end, &v, &vo, &vd);
469 w = B->head->prev;
470 while (u != v) {
471 if (__ISP(u, Texts_PieceDesc, 1)) {
472 wn = (Texts_Run)Texts_ClonePiece(__GUARDP(u, Texts_PieceDesc, 1));
473 wn->len -= ud;
474 __GUARDP(wn, Texts_PieceDesc, 1)->org += ud;
475 } else {
476 wn = (Texts_Run)Texts_CloneElem(__GUARDP(u, Texts_ElemDesc, 1));
477 }
478 w->next = wn;
479 wn->prev = w;
480 w = wn;
481 u = u->next;
482 ud = 0;
483 }
484 if (vd > 0) {
485 wn = (Texts_Run)Texts_ClonePiece(__GUARDP(v, Texts_PieceDesc, 1));
486 wn->len = vd - ud;
487 __GUARDP(wn, Texts_PieceDesc, 1)->org += ud;
488 w->next = wn;
489 wn->prev = w;
490 w = wn;
491 }
492 w->next = B->head;
493 B->head->prev = w;
494 B->len += end - beg;
495 }
496
Texts_Insert(Texts_Text T,INT32 pos,Texts_Buffer B)497 void Texts_Insert (Texts_Text T, INT32 pos, Texts_Buffer B)
498 {
499 Texts_Run u = NIL, un = NIL, v = NIL;
500 Texts_Piece p = NIL, q = NIL;
501 INT32 uo, ud, len;
502 Texts_Find(T, &pos, &u, &uo, &ud);
503 Texts_Split(ud, &u, &un);
504 len = B->len;
505 v = B->head->next;
506 Texts_Merge(T, u, &v);
507 Texts_Splice(un, v, B->head->prev, T);
508 T->len += len;
509 B->head->next = B->head;
510 B->head->prev = B->head;
511 B->len = 0;
512 if (T->notify != NIL) {
513 (*T->notify)(T, 1, pos, pos + len);
514 }
515 }
516
Texts_Append(Texts_Text T,Texts_Buffer B)517 void Texts_Append (Texts_Text T, Texts_Buffer B)
518 {
519 Texts_Run v = NIL;
520 INT32 pos, len;
521 pos = T->len;
522 len = B->len;
523 v = B->head->next;
524 Texts_Merge(T, T->head->prev, &v);
525 Texts_Splice(T->head, v, B->head->prev, T);
526 T->len += len;
527 B->head->next = B->head;
528 B->head->prev = B->head;
529 B->len = 0;
530 if (T->notify != NIL) {
531 (*T->notify)(T, 1, pos, pos + len);
532 }
533 }
534
Texts_Delete(Texts_Text T,INT32 beg,INT32 end)535 void Texts_Delete (Texts_Text T, INT32 beg, INT32 end)
536 {
537 Texts_Run c = NIL, u = NIL, un = NIL, v = NIL, vn = NIL;
538 INT32 co, uo, ud, vo, vd;
539 Texts_Find(T, &beg, &u, &uo, &ud);
540 Texts_Split(ud, &u, &un);
541 c = T->cache;
542 co = T->corg;
543 Texts_Find(T, &end, &v, &vo, &vd);
544 Texts_Split(vd, &v, &vn);
545 T->cache = c;
546 T->corg = co;
547 __NEW(Texts_del, Texts_BufDesc);
548 Texts_OpenBuf(Texts_del);
549 Texts_del->len = end - beg;
550 Texts_Splice(Texts_del->head, un, v, NIL);
551 Texts_Merge(T, u, &vn);
552 u->next = vn;
553 vn->prev = u;
554 T->len -= end - beg;
555 if (T->notify != NIL) {
556 (*T->notify)(T, 2, beg, end);
557 }
558 }
559
Texts_ChangeLooks(Texts_Text T,INT32 beg,INT32 end,UINT32 sel,Texts_FontsFont fnt,INT8 col,INT8 voff)560 void Texts_ChangeLooks (Texts_Text T, INT32 beg, INT32 end, UINT32 sel, Texts_FontsFont fnt, INT8 col, INT8 voff)
561 {
562 Texts_Run c = NIL, u = NIL, un = NIL, v = NIL, vn = NIL;
563 INT32 co, uo, ud, vo, vd;
564 Texts_Find(T, &beg, &u, &uo, &ud);
565 Texts_Split(ud, &u, &un);
566 c = T->cache;
567 co = T->corg;
568 Texts_Find(T, &end, &v, &vo, &vd);
569 Texts_Split(vd, &v, &vn);
570 T->cache = c;
571 T->corg = co;
572 while (un != vn) {
573 if ((__IN(0, sel, 32) && fnt != NIL)) {
574 un->fnt = fnt;
575 }
576 if (__IN(1, sel, 32)) {
577 un->col = col;
578 }
579 if (__IN(2, sel, 32)) {
580 un->voff = voff;
581 }
582 Texts_Merge(T, u, &un);
583 if (u->next == un) {
584 u = un;
585 un = un->next;
586 } else {
587 u->next = un;
588 un->prev = u;
589 }
590 }
591 Texts_Merge(T, u, &un);
592 u->next = un;
593 un->prev = u;
594 if (T->notify != NIL) {
595 (*T->notify)(T, 0, beg, end);
596 }
597 }
598
Texts_OpenReader(Texts_Reader * R,ADDRESS * R__typ,Texts_Text T,INT32 pos)599 void Texts_OpenReader (Texts_Reader *R, ADDRESS *R__typ, Texts_Text T, INT32 pos)
600 {
601 Texts_Run u = NIL;
602 if (pos >= T->len) {
603 pos = T->len;
604 }
605 Texts_Find(T, &pos, &u, &(*R).org, &(*R).off);
606 (*R).run = u;
607 (*R).eot = 0;
608 if (__ISP(u, Texts_PieceDesc, 1)) {
609 Files_Set(&(*R).rider, Files_Rider__typ, __GUARDP(u, Texts_PieceDesc, 1)->file, __GUARDP(u, Texts_PieceDesc, 1)->org + (*R).off);
610 }
611 }
612
Texts_Read(Texts_Reader * R,ADDRESS * R__typ,CHAR * ch)613 void Texts_Read (Texts_Reader *R, ADDRESS *R__typ, CHAR *ch)
614 {
615 Texts_Run u = NIL;
616 INT32 pos;
617 CHAR nextch;
618 u = (*R).run;
619 (*R).fnt = u->fnt;
620 (*R).col = u->col;
621 (*R).voff = u->voff;
622 (*R).off += 1;
623 if (__ISP(u, Texts_PieceDesc, 1)) {
624 Files_Read(&(*R).rider, Files_Rider__typ, (void*)&*ch);
625 (*R).elem = NIL;
626 if ((*ch == 0x0a && __GUARDP(u, Texts_PieceDesc, 1)->ascii)) {
627 *ch = 0x0d;
628 } else if ((*ch == 0x0d && __GUARDP(u, Texts_PieceDesc, 1)->ascii)) {
629 pos = Files_Pos(&(*R).rider, Files_Rider__typ);
630 Files_Read(&(*R).rider, Files_Rider__typ, (void*)&nextch);
631 if (nextch == 0x0a) {
632 (*R).off += 1;
633 } else {
634 Files_Set(&(*R).rider, Files_Rider__typ, __GUARDP(u, Texts_PieceDesc, 1)->file, pos);
635 }
636 }
637 } else if (__ISP(u, Texts_ElemDesc, 1)) {
638 *ch = 0x1c;
639 (*R).elem = __GUARDP(u, Texts_ElemDesc, 1);
640 } else {
641 *ch = 0x00;
642 (*R).elem = NIL;
643 (*R).eot = 1;
644 }
645 if ((*R).off == u->len) {
646 (*R).org += u->len;
647 u = u->next;
648 if (__ISP(u, Texts_PieceDesc, 1)) {
649 if (__ISP(u, Texts_PieceDesc, 1)) {
650 Files_Set(&(*R).rider, Files_Rider__typ, (*(Texts_Piece*)&u)->file, (*(Texts_Piece*)&u)->org);
651 } else __WITHCHK;
652 }
653 (*R).run = u;
654 (*R).off = 0;
655 }
656 }
657
Texts_ReadElem(Texts_Reader * R,ADDRESS * R__typ)658 void Texts_ReadElem (Texts_Reader *R, ADDRESS *R__typ)
659 {
660 Texts_Run u = NIL, un = NIL;
661 u = (*R).run;
662 while (__ISP(u, Texts_PieceDesc, 1)) {
663 (*R).org += u->len;
664 u = u->next;
665 }
666 if (__ISP(u, Texts_ElemDesc, 1)) {
667 un = u->next;
668 (*R).run = un;
669 (*R).org += 1;
670 (*R).off = 0;
671 (*R).fnt = u->fnt;
672 (*R).col = u->col;
673 (*R).voff = u->voff;
674 (*R).elem = __GUARDP(u, Texts_ElemDesc, 1);
675 if (__ISP(un, Texts_PieceDesc, 1)) {
676 if (__ISP(un, Texts_PieceDesc, 1)) {
677 Files_Set(&(*R).rider, Files_Rider__typ, (*(Texts_Piece*)&un)->file, (*(Texts_Piece*)&un)->org);
678 } else __WITHCHK;
679 }
680 } else {
681 (*R).eot = 1;
682 (*R).elem = NIL;
683 }
684 }
685
Texts_ReadPrevElem(Texts_Reader * R,ADDRESS * R__typ)686 void Texts_ReadPrevElem (Texts_Reader *R, ADDRESS *R__typ)
687 {
688 Texts_Run u = NIL;
689 u = (*R).run->prev;
690 while (__ISP(u, Texts_PieceDesc, 1)) {
691 (*R).org -= u->len;
692 u = u->prev;
693 }
694 if (__ISP(u, Texts_ElemDesc, 1)) {
695 (*R).run = u;
696 (*R).org -= 1;
697 (*R).off = 0;
698 (*R).fnt = u->fnt;
699 (*R).col = u->col;
700 (*R).voff = u->voff;
701 (*R).elem = __GUARDP(u, Texts_ElemDesc, 1);
702 } else {
703 (*R).eot = 1;
704 (*R).elem = NIL;
705 }
706 }
707
Texts_Pos(Texts_Reader * R,ADDRESS * R__typ)708 INT32 Texts_Pos (Texts_Reader *R, ADDRESS *R__typ)
709 {
710 return (*R).org + (*R).off;
711 }
712
Texts_OpenScanner(Texts_Scanner * S,ADDRESS * S__typ,Texts_Text T,INT32 pos)713 void Texts_OpenScanner (Texts_Scanner *S, ADDRESS *S__typ, Texts_Text T, INT32 pos)
714 {
715 Texts_OpenReader((void*)&*S, S__typ, T, pos);
716 (*S).line = 0;
717 (*S).nextCh = ' ';
718 }
719
720 static struct Scan__31 {
721 Texts_Scanner *S;
722 ADDRESS *S__typ;
723 CHAR *ch;
724 BOOLEAN *negE;
725 INT16 *e;
726 struct Scan__31 *lnk;
727 } *Scan__31_s;
728
729 static void ReadScaleFactor__32 (void);
730
ReadScaleFactor__32(void)731 static void ReadScaleFactor__32 (void)
732 {
733 Texts_Read((void*)&*Scan__31_s->S, Scan__31_s->S__typ, &*Scan__31_s->ch);
734 if (*Scan__31_s->ch == '-') {
735 *Scan__31_s->negE = 1;
736 Texts_Read((void*)&*Scan__31_s->S, Scan__31_s->S__typ, &*Scan__31_s->ch);
737 } else {
738 *Scan__31_s->negE = 0;
739 if (*Scan__31_s->ch == '+') {
740 Texts_Read((void*)&*Scan__31_s->S, Scan__31_s->S__typ, &*Scan__31_s->ch);
741 }
742 }
743 while (('0' <= *Scan__31_s->ch && *Scan__31_s->ch <= '9')) {
744 *Scan__31_s->e = (*Scan__31_s->e * 10 + (INT16)*Scan__31_s->ch) - 48;
745 Texts_Read((void*)&*Scan__31_s->S, Scan__31_s->S__typ, &*Scan__31_s->ch);
746 }
747 }
748
Texts_Scan(Texts_Scanner * S,ADDRESS * S__typ)749 void Texts_Scan (Texts_Scanner *S, ADDRESS *S__typ)
750 {
751 CHAR ch, term;
752 BOOLEAN neg, negE, hex;
753 INT8 i, j, h;
754 INT16 e;
755 INT32 k;
756 REAL x, f;
757 LONGREAL y, g;
758 CHAR d[32];
759 struct Scan__31 _s;
760 _s.S = S; _s.S__typ = S__typ;
761 _s.ch = &ch;
762 _s.negE = &negE;
763 _s.e = &e;
764 _s.lnk = Scan__31_s;
765 Scan__31_s = &_s;
766 ch = (*S).nextCh;
767 i = 0;
768 for (;;) {
769 if (ch == 0x0d) {
770 (*S).line += 1;
771 } else if ((ch != ' ' && ch != 0x09)) {
772 break;
773 }
774 Texts_Read((void*)&*S, S__typ, &ch);
775 }
776 if ((('A' <= __CAP(ch) && __CAP(ch) <= 'Z') || ch == '/') || ch == '.') {
777 do {
778 (*S).s[__X(i, 64)] = ch;
779 i += 1;
780 Texts_Read((void*)&*S, S__typ, &ch);
781 } while (!((((__CAP(ch) > 'Z' && ch != '_') || ('A' > __CAP(ch) && ch > '9')) || ((('0' > ch && ch != '.')) && ch != '/')) || i == 63));
782 (*S).s[__X(i, 64)] = 0x00;
783 (*S).len = i;
784 (*S).class = 1;
785 } else if (ch == '"') {
786 Texts_Read((void*)&*S, S__typ, &ch);
787 while ((((ch != '"' && ch >= ' ')) && i != 63)) {
788 (*S).s[__X(i, 64)] = ch;
789 i += 1;
790 Texts_Read((void*)&*S, S__typ, &ch);
791 }
792 (*S).s[__X(i, 64)] = 0x00;
793 (*S).len = i + 1;
794 Texts_Read((void*)&*S, S__typ, &ch);
795 (*S).class = 2;
796 } else {
797 if (ch == '-') {
798 neg = 1;
799 Texts_Read((void*)&*S, S__typ, &ch);
800 } else {
801 neg = 0;
802 }
803 if (('0' <= ch && ch <= '9')) {
804 hex = 0;
805 j = 0;
806 for (;;) {
807 d[__X(i, 32)] = ch;
808 i += 1;
809 Texts_Read((void*)&*S, S__typ, &ch);
810 if (ch < '0') {
811 break;
812 }
813 if ('9' < ch) {
814 if (('A' <= ch && ch <= 'F')) {
815 hex = 1;
816 ch = __CHR((INT16)ch - 7);
817 } else if (('a' <= ch && ch <= 'f')) {
818 hex = 1;
819 ch = __CHR((INT16)ch - 39);
820 } else {
821 break;
822 }
823 }
824 }
825 if (ch == 'H') {
826 Texts_Read((void*)&*S, S__typ, &ch);
827 (*S).class = 3;
828 if (i - j > 8) {
829 j = i - 8;
830 }
831 k = (INT16)d[__X(j, 32)] - 48;
832 j += 1;
833 if ((i - j == 7 && k >= 8)) {
834 k -= 16;
835 }
836 while (j < i) {
837 k = __ASHL(k, 4) + ((INT16)d[__X(j, 32)] - 48);
838 j += 1;
839 }
840 if (neg) {
841 (*S).i = -k;
842 } else {
843 (*S).i = k;
844 }
845 } else if (ch == '.') {
846 Texts_Read((void*)&*S, S__typ, &ch);
847 h = i;
848 while (('0' <= ch && ch <= '9')) {
849 d[__X(i, 32)] = ch;
850 i += 1;
851 Texts_Read((void*)&*S, S__typ, &ch);
852 }
853 if (ch == 'D') {
854 e = 0;
855 y = (LONGREAL)0;
856 g = (LONGREAL)1;
857 do {
858 y = y * (LONGREAL)10 + ((INT16)d[__X(j, 32)] - 48);
859 j += 1;
860 } while (!(j == h));
861 while (j < i) {
862 g = g / (LONGREAL)(LONGREAL)10;
863 y = ((INT16)d[__X(j, 32)] - 48) * g + y;
864 j += 1;
865 }
866 ReadScaleFactor__32();
867 if (negE) {
868 if (e <= 308) {
869 y = y / (LONGREAL)Reals_TenL(e);
870 } else {
871 y = (LONGREAL)0;
872 }
873 } else if (e > 0) {
874 if (e <= 308) {
875 y = Reals_TenL(e) * y;
876 } else {
877 __HALT(40);
878 }
879 }
880 if (neg) {
881 y = -y;
882 }
883 (*S).class = 5;
884 (*S).y = y;
885 } else {
886 e = 0;
887 x = (REAL)0;
888 f = (REAL)1;
889 do {
890 x = x * (REAL)10 + ((INT16)d[__X(j, 32)] - 48);
891 j += 1;
892 } while (!(j == h));
893 while (j < i) {
894 f = f / (REAL)(REAL)10;
895 x = ((INT16)d[__X(j, 32)] - 48) * f + x;
896 j += 1;
897 }
898 if (ch == 'E') {
899 ReadScaleFactor__32();
900 }
901 if (negE) {
902 if (e <= 38) {
903 x = x / (REAL)Reals_Ten(e);
904 } else {
905 x = (REAL)0;
906 }
907 } else if (e > 0) {
908 if (e <= 38) {
909 x = Reals_Ten(e) * x;
910 } else {
911 __HALT(40);
912 }
913 }
914 if (neg) {
915 x = -x;
916 }
917 (*S).class = 4;
918 (*S).x = x;
919 }
920 if (hex) {
921 (*S).class = 0;
922 }
923 } else {
924 (*S).class = 3;
925 k = 0;
926 do {
927 k = k * 10 + ((INT16)d[__X(j, 32)] - 48);
928 j += 1;
929 } while (!(j == i));
930 if (neg) {
931 (*S).i = -k;
932 } else {
933 (*S).i = k;
934 }
935 if (hex) {
936 (*S).class = 0;
937 } else {
938 (*S).class = 3;
939 }
940 }
941 } else {
942 (*S).class = 6;
943 if (neg) {
944 (*S).c = '-';
945 } else {
946 (*S).c = ch;
947 Texts_Read((void*)&*S, S__typ, &ch);
948 }
949 }
950 }
951 (*S).nextCh = ch;
952 Scan__31_s = _s.lnk;
953 }
954
Texts_OpenWriter(Texts_Writer * W,ADDRESS * W__typ)955 void Texts_OpenWriter (Texts_Writer *W, ADDRESS *W__typ)
956 {
957 __NEW((*W).buf, Texts_BufDesc);
958 Texts_OpenBuf((*W).buf);
959 (*W).fnt = Texts_FontsDefault;
960 (*W).col = 15;
961 (*W).voff = 0;
962 (*W).file = Files_New((CHAR*)"", 1);
963 Files_Set(&(*W).rider, Files_Rider__typ, (*W).file, 0);
964 }
965
Texts_SetFont(Texts_Writer * W,ADDRESS * W__typ,Texts_FontsFont fnt)966 void Texts_SetFont (Texts_Writer *W, ADDRESS *W__typ, Texts_FontsFont fnt)
967 {
968 (*W).fnt = fnt;
969 }
970
Texts_SetColor(Texts_Writer * W,ADDRESS * W__typ,INT8 col)971 void Texts_SetColor (Texts_Writer *W, ADDRESS *W__typ, INT8 col)
972 {
973 (*W).col = col;
974 }
975
Texts_SetOffset(Texts_Writer * W,ADDRESS * W__typ,INT8 voff)976 void Texts_SetOffset (Texts_Writer *W, ADDRESS *W__typ, INT8 voff)
977 {
978 (*W).voff = voff;
979 }
980
Texts_Write(Texts_Writer * W,ADDRESS * W__typ,CHAR ch)981 void Texts_Write (Texts_Writer *W, ADDRESS *W__typ, CHAR ch)
982 {
983 Texts_Run u = NIL, un = NIL;
984 Texts_Piece p = NIL;
985 Files_Write(&(*W).rider, Files_Rider__typ, ch);
986 (*W).buf->len += 1;
987 un = (*W).buf->head;
988 u = un->prev;
989 if ((((((((((__ISP(u, Texts_PieceDesc, 1) && __GUARDP(u, Texts_PieceDesc, 1)->file == (*W).file)) && __STRCMP(u->fnt->name, (*W).fnt->name) == 0)) && u->col == (*W).col)) && u->voff == (*W).voff)) && !__GUARDP(u, Texts_PieceDesc, 1)->ascii)) {
990 u->len += 1;
991 } else {
992 __NEW(p, Texts_PieceDesc);
993 u->next = (Texts_Run)p;
994 p->prev = u;
995 p->next = un;
996 un->prev = (Texts_Run)p;
997 p->len = 1;
998 p->fnt = (*W).fnt;
999 p->col = (*W).col;
1000 p->voff = (*W).voff;
1001 p->file = (*W).file;
1002 p->org = Files_Length((*W).file) - 1;
1003 p->ascii = 0;
1004 }
1005 }
1006
Texts_WriteElem(Texts_Writer * W,ADDRESS * W__typ,Texts_Elem e)1007 void Texts_WriteElem (Texts_Writer *W, ADDRESS *W__typ, Texts_Elem e)
1008 {
1009 Texts_Run u = NIL, un = NIL;
1010 if (e->base != NIL) {
1011 __HALT(99);
1012 }
1013 (*W).buf->len += 1;
1014 e->len = 1;
1015 e->fnt = (*W).fnt;
1016 e->col = (*W).col;
1017 e->voff = (*W).voff;
1018 un = (*W).buf->head;
1019 u = un->prev;
1020 u->next = (Texts_Run)e;
1021 e->prev = u;
1022 e->next = un;
1023 un->prev = (Texts_Run)e;
1024 }
1025
Texts_WriteLn(Texts_Writer * W,ADDRESS * W__typ)1026 void Texts_WriteLn (Texts_Writer *W, ADDRESS *W__typ)
1027 {
1028 Texts_Write(&*W, W__typ, 0x0d);
1029 }
1030
Texts_WriteString(Texts_Writer * W,ADDRESS * W__typ,CHAR * s,ADDRESS s__len)1031 void Texts_WriteString (Texts_Writer *W, ADDRESS *W__typ, CHAR *s, ADDRESS s__len)
1032 {
1033 INT16 i;
1034 __DUP(s, s__len, CHAR);
1035 i = 0;
1036 while (s[__X(i, s__len)] >= ' ') {
1037 Texts_Write(&*W, W__typ, s[__X(i, s__len)]);
1038 i += 1;
1039 }
1040 __DEL(s);
1041 }
1042
Texts_WriteInt(Texts_Writer * W,ADDRESS * W__typ,INT64 x,INT64 n)1043 void Texts_WriteInt (Texts_Writer *W, ADDRESS *W__typ, INT64 x, INT64 n)
1044 {
1045 INT16 i;
1046 INT64 x0;
1047 CHAR a[24];
1048 i = 0;
1049 if (x < 0) {
1050 if (x == (-9223372036854775807LL-1)) {
1051 Texts_WriteString(&*W, W__typ, (CHAR*)" -9223372036854775808", 22);
1052 return;
1053 } else {
1054 n -= 1;
1055 x0 = -x;
1056 }
1057 } else {
1058 x0 = x;
1059 }
1060 do {
1061 a[__X(i, 24)] = __CHR(__MOD(x0, 10) + 48);
1062 x0 = __DIV(x0, 10);
1063 i += 1;
1064 } while (!(x0 == 0));
1065 while (n > (INT64)i) {
1066 Texts_Write(&*W, W__typ, ' ');
1067 n -= 1;
1068 }
1069 if (x < 0) {
1070 Texts_Write(&*W, W__typ, '-');
1071 }
1072 do {
1073 i -= 1;
1074 Texts_Write(&*W, W__typ, a[__X(i, 24)]);
1075 } while (!(i == 0));
1076 }
1077
Texts_WriteHex(Texts_Writer * W,ADDRESS * W__typ,INT32 x)1078 void Texts_WriteHex (Texts_Writer *W, ADDRESS *W__typ, INT32 x)
1079 {
1080 INT16 i;
1081 INT32 y;
1082 CHAR a[20];
1083 i = 0;
1084 Texts_Write(&*W, W__typ, ' ');
1085 do {
1086 y = __MASK(x, -16);
1087 if (y < 10) {
1088 a[__X(i, 20)] = __CHR(y + 48);
1089 } else {
1090 a[__X(i, 20)] = __CHR(y + 55);
1091 }
1092 x = __ASHR(x, 4);
1093 i += 1;
1094 } while (!(i == 8));
1095 do {
1096 i -= 1;
1097 Texts_Write(&*W, W__typ, a[__X(i, 20)]);
1098 } while (!(i == 0));
1099 }
1100
Texts_WriteReal(Texts_Writer * W,ADDRESS * W__typ,REAL x,INT16 n)1101 void Texts_WriteReal (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n)
1102 {
1103 INT16 e;
1104 REAL x0;
1105 CHAR d[9];
1106 e = Reals_Expo(x);
1107 if (e == 0) {
1108 Texts_WriteString(&*W, W__typ, (CHAR*)" 0", 4);
1109 do {
1110 Texts_Write(&*W, W__typ, ' ');
1111 n -= 1;
1112 } while (!(n <= 3));
1113 } else if (e == 255) {
1114 Texts_WriteString(&*W, W__typ, (CHAR*)" NaN", 5);
1115 while (n > 4) {
1116 Texts_Write(&*W, W__typ, ' ');
1117 n -= 1;
1118 }
1119 } else {
1120 if (n <= 9) {
1121 n = 3;
1122 } else {
1123 n -= 6;
1124 }
1125 do {
1126 Texts_Write(&*W, W__typ, ' ');
1127 n -= 1;
1128 } while (!(n <= 8));
1129 if (x < (REAL)0) {
1130 Texts_Write(&*W, W__typ, '-');
1131 x = -x;
1132 } else {
1133 Texts_Write(&*W, W__typ, ' ');
1134 }
1135 e = __ASHR((e - 127) * 77, 8);
1136 if (e >= 0) {
1137 x = x / (REAL)Reals_Ten(e);
1138 } else {
1139 x = Reals_Ten(-e) * x;
1140 }
1141 if (x >= (REAL)10) {
1142 x = 1.0000000e-001 * x;
1143 e += 1;
1144 }
1145 x0 = Reals_Ten(n - 1);
1146 x = x0 * x + 5.0000000e-001;
1147 if (x >= (REAL)10 * x0) {
1148 x = x * 1.0000000e-001;
1149 e += 1;
1150 }
1151 Reals_Convert(x, n, (void*)d, 9);
1152 n -= 1;
1153 Texts_Write(&*W, W__typ, d[__X(n, 9)]);
1154 Texts_Write(&*W, W__typ, '.');
1155 do {
1156 n -= 1;
1157 Texts_Write(&*W, W__typ, d[__X(n, 9)]);
1158 } while (!(n == 0));
1159 Texts_Write(&*W, W__typ, 'E');
1160 if (e < 0) {
1161 Texts_Write(&*W, W__typ, '-');
1162 e = -e;
1163 } else {
1164 Texts_Write(&*W, W__typ, '+');
1165 }
1166 Texts_Write(&*W, W__typ, __CHR(__DIV(e, 10) + 48));
1167 Texts_Write(&*W, W__typ, __CHR((int)__MOD(e, 10) + 48));
1168 }
1169 }
1170
1171 static struct WriteRealFix__53 {
1172 Texts_Writer *W;
1173 ADDRESS *W__typ;
1174 INT16 *i;
1175 CHAR (*d)[9];
1176 struct WriteRealFix__53 *lnk;
1177 } *WriteRealFix__53_s;
1178
1179 static void dig__54 (INT16 n);
1180 static void seq__56 (CHAR ch, INT16 n);
1181
seq__56(CHAR ch,INT16 n)1182 static void seq__56 (CHAR ch, INT16 n)
1183 {
1184 while (n > 0) {
1185 Texts_Write(&*WriteRealFix__53_s->W, WriteRealFix__53_s->W__typ, ch);
1186 n -= 1;
1187 }
1188 }
1189
dig__54(INT16 n)1190 static void dig__54 (INT16 n)
1191 {
1192 while (n > 0) {
1193 *WriteRealFix__53_s->i -= 1;
1194 Texts_Write(&*WriteRealFix__53_s->W, WriteRealFix__53_s->W__typ, (*WriteRealFix__53_s->d)[__X(*WriteRealFix__53_s->i, 9)]);
1195 n -= 1;
1196 }
1197 }
1198
Texts_WriteRealFix(Texts_Writer * W,ADDRESS * W__typ,REAL x,INT16 n,INT16 k)1199 void Texts_WriteRealFix (Texts_Writer *W, ADDRESS *W__typ, REAL x, INT16 n, INT16 k)
1200 {
1201 INT16 e, i;
1202 CHAR sign;
1203 REAL x0;
1204 CHAR d[9];
1205 struct WriteRealFix__53 _s;
1206 _s.W = W; _s.W__typ = W__typ;
1207 _s.i = &i;
1208 _s.d = (void*)d;
1209 _s.lnk = WriteRealFix__53_s;
1210 WriteRealFix__53_s = &_s;
1211 e = Reals_Expo(x);
1212 if (k < 0) {
1213 k = 0;
1214 }
1215 if (e == 0) {
1216 seq__56(' ', (n - k) - 2);
1217 Texts_Write(&*W, W__typ, '0');
1218 seq__56(' ', k + 1);
1219 } else if (e == 255) {
1220 Texts_WriteString(&*W, W__typ, (CHAR*)" NaN", 5);
1221 seq__56(' ', n - 4);
1222 } else {
1223 e = __ASHR((e - 127) * 77, 8);
1224 if (x < (REAL)0) {
1225 sign = '-';
1226 x = -x;
1227 } else {
1228 sign = ' ';
1229 }
1230 if (e >= 0) {
1231 x = x / (REAL)Reals_Ten(e);
1232 } else {
1233 x = Reals_Ten(-e) * x;
1234 }
1235 if (x >= (REAL)10) {
1236 x = 1.0000000e-001 * x;
1237 e += 1;
1238 }
1239 if (k + e >= 8) {
1240 k = 8 - e;
1241 } else if (k + e < 0) {
1242 k = -e;
1243 x = (REAL)0;
1244 }
1245 x0 = Reals_Ten(k + e);
1246 x = x0 * x + 5.0000000e-001;
1247 if (x >= (REAL)10 * x0) {
1248 e += 1;
1249 }
1250 e += 1;
1251 i = k + e;
1252 Reals_Convert(x, i, (void*)d, 9);
1253 if (e > 0) {
1254 seq__56(' ', ((n - e) - k) - 2);
1255 Texts_Write(&*W, W__typ, sign);
1256 dig__54(e);
1257 Texts_Write(&*W, W__typ, '.');
1258 dig__54(k);
1259 } else {
1260 seq__56(' ', (n - k) - 3);
1261 Texts_Write(&*W, W__typ, sign);
1262 Texts_Write(&*W, W__typ, '0');
1263 Texts_Write(&*W, W__typ, '.');
1264 seq__56('0', -e);
1265 dig__54(k + e);
1266 }
1267 }
1268 WriteRealFix__53_s = _s.lnk;
1269 }
1270
Texts_WriteRealHex(Texts_Writer * W,ADDRESS * W__typ,REAL x)1271 void Texts_WriteRealHex (Texts_Writer *W, ADDRESS *W__typ, REAL x)
1272 {
1273 INT16 i;
1274 CHAR d[8];
1275 Reals_ConvertH(x, (void*)d, 8);
1276 i = 0;
1277 do {
1278 Texts_Write(&*W, W__typ, d[__X(i, 8)]);
1279 i += 1;
1280 } while (!(i == 8));
1281 }
1282
Texts_WriteLongReal(Texts_Writer * W,ADDRESS * W__typ,LONGREAL x,INT16 n)1283 void Texts_WriteLongReal (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x, INT16 n)
1284 {
1285 INT16 e;
1286 LONGREAL x0;
1287 CHAR d[16];
1288 e = Reals_ExpoL(x);
1289 if (e == 0) {
1290 Texts_WriteString(&*W, W__typ, (CHAR*)" 0", 4);
1291 do {
1292 Texts_Write(&*W, W__typ, ' ');
1293 n -= 1;
1294 } while (!(n <= 3));
1295 } else if (e == 2047) {
1296 Texts_WriteString(&*W, W__typ, (CHAR*)" NaN", 5);
1297 while (n > 4) {
1298 Texts_Write(&*W, W__typ, ' ');
1299 n -= 1;
1300 }
1301 } else {
1302 if (n <= 10) {
1303 n = 3;
1304 } else {
1305 n -= 7;
1306 }
1307 do {
1308 Texts_Write(&*W, W__typ, ' ');
1309 n -= 1;
1310 } while (!(n <= 16));
1311 if (x < (LONGREAL)0) {
1312 Texts_Write(&*W, W__typ, '-');
1313 x = -x;
1314 } else {
1315 Texts_Write(&*W, W__typ, ' ');
1316 }
1317 e = __SHORT(__ASHR((e - 1023) * 77, 8), 32768);
1318 if (e >= 0) {
1319 x = x / (LONGREAL)Reals_TenL(e);
1320 } else {
1321 x = Reals_TenL(-e) * x;
1322 }
1323 if (x >= (LONGREAL)10) {
1324 x = 1.00000000000000e-001 * x;
1325 e += 1;
1326 }
1327 x0 = Reals_TenL(n - 1);
1328 x = x0 * x + 5.00000000000000e-001;
1329 if (x >= (LONGREAL)10 * x0) {
1330 x = 1.00000000000000e-001 * x;
1331 e += 1;
1332 }
1333 Reals_ConvertL(x, n, (void*)d, 16);
1334 n -= 1;
1335 Texts_Write(&*W, W__typ, d[__X(n, 16)]);
1336 Texts_Write(&*W, W__typ, '.');
1337 do {
1338 n -= 1;
1339 Texts_Write(&*W, W__typ, d[__X(n, 16)]);
1340 } while (!(n == 0));
1341 Texts_Write(&*W, W__typ, 'D');
1342 if (e < 0) {
1343 Texts_Write(&*W, W__typ, '-');
1344 e = -e;
1345 } else {
1346 Texts_Write(&*W, W__typ, '+');
1347 }
1348 Texts_Write(&*W, W__typ, __CHR(__DIV(e, 100) + 48));
1349 e = (int)__MOD(e, 100);
1350 Texts_Write(&*W, W__typ, __CHR(__DIV(e, 10) + 48));
1351 Texts_Write(&*W, W__typ, __CHR((int)__MOD(e, 10) + 48));
1352 }
1353 }
1354
Texts_WriteLongRealHex(Texts_Writer * W,ADDRESS * W__typ,LONGREAL x)1355 void Texts_WriteLongRealHex (Texts_Writer *W, ADDRESS *W__typ, LONGREAL x)
1356 {
1357 INT16 i;
1358 CHAR d[16];
1359 Reals_ConvertHL(x, (void*)d, 16);
1360 i = 0;
1361 do {
1362 Texts_Write(&*W, W__typ, d[__X(i, 16)]);
1363 i += 1;
1364 } while (!(i == 16));
1365 }
1366
1367 static struct WriteDate__43 {
1368 Texts_Writer *W;
1369 ADDRESS *W__typ;
1370 struct WriteDate__43 *lnk;
1371 } *WriteDate__43_s;
1372
1373 static void WritePair__44 (CHAR ch, INT32 x);
1374
WritePair__44(CHAR ch,INT32 x)1375 static void WritePair__44 (CHAR ch, INT32 x)
1376 {
1377 Texts_Write(&*WriteDate__43_s->W, WriteDate__43_s->W__typ, ch);
1378 Texts_Write(&*WriteDate__43_s->W, WriteDate__43_s->W__typ, __CHR(__DIV(x, 10) + 48));
1379 Texts_Write(&*WriteDate__43_s->W, WriteDate__43_s->W__typ, __CHR((int)__MOD(x, 10) + 48));
1380 }
1381
Texts_WriteDate(Texts_Writer * W,ADDRESS * W__typ,INT32 t,INT32 d)1382 void Texts_WriteDate (Texts_Writer *W, ADDRESS *W__typ, INT32 t, INT32 d)
1383 {
1384 struct WriteDate__43 _s;
1385 _s.W = W; _s.W__typ = W__typ;
1386 _s.lnk = WriteDate__43_s;
1387 WriteDate__43_s = &_s;
1388 WritePair__44(' ', __MASK(d, -32));
1389 WritePair__44('.', __MASK(__ASHR(d, 5), -16));
1390 WritePair__44('.', __MASK(__ASHR(d, 9), -128));
1391 WritePair__44(' ', __MASK(__ASHR(t, 12), -32));
1392 WritePair__44(':', __MASK(__ASHR(t, 6), -64));
1393 WritePair__44(':', __MASK(t, -64));
1394 WriteDate__43_s = _s.lnk;
1395 }
1396
1397 static struct Load0__16 {
1398 Texts_Text *T;
1399 INT8 *ecnt;
1400 Files_File *f;
1401 Texts_FileMsg *msg;
1402 CHAR (*mods)[64][32], (*procs)[64][32];
1403 struct Load0__16 *lnk;
1404 } *Load0__16_s;
1405
1406 static void LoadElem__17 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e);
1407
LoadElem__17(Files_Rider * r,ADDRESS * r__typ,INT32 pos,INT32 span,Texts_Elem * e)1408 static void LoadElem__17 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, INT32 span, Texts_Elem *e)
1409 {
1410 Heap_Module M = NIL;
1411 Heap_Command Cmd;
1412 Texts_Alien a = NIL;
1413 INT32 org, ew, eh;
1414 INT8 eno;
1415 Texts_new = NIL;
1416 Files_ReadLInt(&*r, r__typ, &ew);
1417 Files_ReadLInt(&*r, r__typ, &eh);
1418 Files_Read(&*r, r__typ, (void*)&eno);
1419 if (eno > *Load0__16_s->ecnt) {
1420 *Load0__16_s->ecnt = eno;
1421 Files_ReadString(&*r, r__typ, (void*)(*Load0__16_s->mods)[__X(eno, 64)], 32);
1422 Files_ReadString(&*r, r__typ, (void*)(*Load0__16_s->procs)[__X(eno, 64)], 32);
1423 }
1424 org = Files_Pos(&*r, r__typ);
1425 M = Modules_ThisMod((*Load0__16_s->mods)[__X(eno, 64)], 32);
1426 if (M != NIL) {
1427 Cmd = Modules_ThisCommand(M, (*Load0__16_s->procs)[__X(eno, 64)], 32);
1428 if (Cmd != NIL) {
1429 (*Cmd)();
1430 }
1431 }
1432 *e = Texts_new;
1433 if (*e != NIL) {
1434 (*e)->W = ew;
1435 (*e)->H = eh;
1436 (*e)->base = *Load0__16_s->T;
1437 (*Load0__16_s->msg).pos = pos;
1438 (*(*e)->handle)(*e, (void*)&*Load0__16_s->msg, Texts_FileMsg__typ);
1439 if (Files_Pos(&*r, r__typ) != org + span) {
1440 *e = NIL;
1441 }
1442 }
1443 if (*e == NIL) {
1444 Files_Set(&*r, r__typ, *Load0__16_s->f, org + span);
1445 __NEW(a, Texts__1);
1446 a->W = ew;
1447 a->H = eh;
1448 a->handle = Texts_HandleAlien;
1449 a->base = *Load0__16_s->T;
1450 a->file = *Load0__16_s->f;
1451 a->org = org;
1452 a->span = span;
1453 __COPY((*Load0__16_s->mods)[__X(eno, 64)], a->mod, 32);
1454 __COPY((*Load0__16_s->procs)[__X(eno, 64)], a->proc, 32);
1455 *e = (Texts_Elem)a;
1456 }
1457 }
1458
Texts_Load0(Files_Rider * r,ADDRESS * r__typ,Texts_Text T)1459 static void Texts_Load0 (Files_Rider *r, ADDRESS *r__typ, Texts_Text T)
1460 {
1461 Texts_Run u = NIL, un = NIL;
1462 Texts_Piece p = NIL;
1463 Texts_Elem e = NIL;
1464 INT32 org, pos, hlen, plen;
1465 INT8 ecnt, fcnt, fno, col, voff;
1466 Files_File f = NIL;
1467 Texts_FileMsg msg;
1468 CHAR mods[64][32], procs[64][32];
1469 CHAR name[32];
1470 Texts_FontsFont fnts[32];
1471 struct Load0__16 _s;
1472 _s.T = &T;
1473 _s.ecnt = &ecnt;
1474 _s.f = &f;
1475 _s.msg = &msg;
1476 _s.mods = (void*)mods;
1477 _s.procs = (void*)procs;
1478 _s.lnk = Load0__16_s;
1479 Load0__16_s = &_s;
1480 pos = Files_Pos(&*r, r__typ);
1481 f = Files_Base(&*r, r__typ);
1482 __NEW(u, Texts_RunDesc);
1483 u->len = 2147483647;
1484 u->fnt = NIL;
1485 u->col = 15;
1486 T->head = u;
1487 ecnt = 0;
1488 fcnt = 0;
1489 msg.id = 0;
1490 msg.r = *r;
1491 Files_ReadLInt(&msg.r, Files_Rider__typ, &hlen);
1492 org = (pos - 2) + hlen;
1493 pos = org;
1494 Files_Read(&msg.r, Files_Rider__typ, (void*)&fno);
1495 while (fno != 0) {
1496 if (fno > fcnt) {
1497 fcnt = fno;
1498 Files_ReadString(&msg.r, Files_Rider__typ, (void*)name, 32);
1499 fnts[__X(fno, 32)] = Texts_FontsThis((void*)name, 32);
1500 }
1501 Files_Read(&msg.r, Files_Rider__typ, (void*)&col);
1502 Files_Read(&msg.r, Files_Rider__typ, (void*)&voff);
1503 Files_ReadLInt(&msg.r, Files_Rider__typ, &plen);
1504 if (plen > 0) {
1505 __NEW(p, Texts_PieceDesc);
1506 p->file = f;
1507 p->org = pos;
1508 p->ascii = 0;
1509 un = (Texts_Run)p;
1510 un->len = plen;
1511 } else {
1512 LoadElem__17(&msg.r, Files_Rider__typ, pos - org, -plen, &e);
1513 un = (Texts_Run)e;
1514 un->len = 1;
1515 }
1516 un->col = col;
1517 un->voff = voff;
1518 pos += un->len;
1519 u->next = un;
1520 un->prev = u;
1521 u = un;
1522 Files_Read(&msg.r, Files_Rider__typ, (void*)&fno);
1523 }
1524 u->next = T->head;
1525 T->head->prev = u;
1526 T->cache = T->head;
1527 T->corg = 0;
1528 Files_ReadLInt(&msg.r, Files_Rider__typ, &T->len);
1529 Files_Set(&*r, r__typ, f, Files_Pos(&msg.r, Files_Rider__typ) + T->len);
1530 Load0__16_s = _s.lnk;
1531 }
1532
Texts_Load(Files_Rider * r,ADDRESS * r__typ,Texts_Text T)1533 void Texts_Load (Files_Rider *r, ADDRESS *r__typ, Texts_Text T)
1534 {
1535 INT16 tag;
1536 Files_ReadInt(&*r, r__typ, &tag);
1537 if (tag != -4095) {
1538 Files_Set(&*r, r__typ, Files_Base(&*r, r__typ), Files_Pos(&*r, r__typ) - 2);
1539 }
1540 Texts_Load0(&*r, r__typ, T);
1541 }
1542
Texts_Open(Texts_Text T,CHAR * name,ADDRESS name__len)1543 void Texts_Open (Texts_Text T, CHAR *name, ADDRESS name__len)
1544 {
1545 Files_File f = NIL;
1546 Files_Rider r;
1547 Texts_Run u = NIL;
1548 Texts_Piece p = NIL;
1549 CHAR tag, version;
1550 INT32 hlen;
1551 __DUP(name, name__len, CHAR);
1552 f = Files_Old(name, name__len);
1553 if (f == NIL) {
1554 f = Files_New((CHAR*)"", 1);
1555 }
1556 Files_Set(&r, Files_Rider__typ, f, 0);
1557 Files_Read(&r, Files_Rider__typ, (void*)&tag);
1558 Files_Read(&r, Files_Rider__typ, (void*)&version);
1559 if (tag == 0xf0 || (tag == 0x01 && version == 0xf0)) {
1560 Texts_Load0(&r, Files_Rider__typ, T);
1561 } else {
1562 __NEW(u, Texts_RunDesc);
1563 u->len = 2147483647;
1564 u->fnt = NIL;
1565 u->col = 15;
1566 __NEW(p, Texts_PieceDesc);
1567 if ((tag == 0xf7 && version == 0x07)) {
1568 Files_Set(&r, Files_Rider__typ, f, 28);
1569 Files_ReadLInt(&r, Files_Rider__typ, &hlen);
1570 Files_Set(&r, Files_Rider__typ, f, 22 + hlen);
1571 Files_ReadLInt(&r, Files_Rider__typ, &T->len);
1572 p->org = 26 + hlen;
1573 } else {
1574 T->len = Files_Length(f);
1575 p->org = 0;
1576 }
1577 if (T->len > 0) {
1578 p->len = T->len;
1579 p->fnt = Texts_FontsDefault;
1580 p->col = 15;
1581 p->voff = 0;
1582 p->file = f;
1583 p->ascii = 1;
1584 u->next = (Texts_Run)p;
1585 u->prev = (Texts_Run)p;
1586 p->next = u;
1587 p->prev = u;
1588 } else {
1589 u->next = u;
1590 u->prev = u;
1591 }
1592 T->head = u;
1593 T->cache = T->head;
1594 T->corg = 0;
1595 }
1596 __DEL(name);
1597 }
1598
1599 static struct Store__39 {
1600 INT8 *ecnt;
1601 Texts_FileMsg *msg;
1602 Texts_IdentifyMsg *iden;
1603 CHAR (*mods)[64][32], (*procs)[64][32];
1604 struct Store__39 *lnk;
1605 } *Store__39_s;
1606
1607 static void StoreElem__40 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, Texts_Elem e);
1608
StoreElem__40(Files_Rider * r,ADDRESS * r__typ,INT32 pos,Texts_Elem e)1609 static void StoreElem__40 (Files_Rider *r, ADDRESS *r__typ, INT32 pos, Texts_Elem e)
1610 {
1611 Files_Rider r1;
1612 INT32 org, span;
1613 INT8 eno;
1614 __COPY((*Store__39_s->iden).mod, (*Store__39_s->mods)[__X(*Store__39_s->ecnt, 64)], 32);
1615 __COPY((*Store__39_s->iden).proc, (*Store__39_s->procs)[__X(*Store__39_s->ecnt, 64)], 32);
1616 eno = 1;
1617 while (__STRCMP((*Store__39_s->mods)[__X(eno, 64)], (*Store__39_s->iden).mod) != 0 || __STRCMP((*Store__39_s->procs)[__X(eno, 64)], (*Store__39_s->iden).proc) != 0) {
1618 eno += 1;
1619 }
1620 Files_Set(&r1, Files_Rider__typ, Files_Base(&*r, r__typ), Files_Pos(&*r, r__typ));
1621 Files_WriteLInt(&*r, r__typ, 0);
1622 Files_WriteLInt(&*r, r__typ, 0);
1623 Files_WriteLInt(&*r, r__typ, 0);
1624 Files_Write(&*r, r__typ, eno);
1625 if (eno == *Store__39_s->ecnt) {
1626 *Store__39_s->ecnt += 1;
1627 Files_WriteString(&*r, r__typ, (*Store__39_s->iden).mod, 32);
1628 Files_WriteString(&*r, r__typ, (*Store__39_s->iden).proc, 32);
1629 }
1630 (*Store__39_s->msg).pos = pos;
1631 org = Files_Pos(&*r, r__typ);
1632 (*e->handle)(e, (void*)&*Store__39_s->msg, Texts_FileMsg__typ);
1633 span = Files_Pos(&*r, r__typ) - org;
1634 Files_WriteLInt(&r1, Files_Rider__typ, -span);
1635 Files_WriteLInt(&r1, Files_Rider__typ, e->W);
1636 Files_WriteLInt(&r1, Files_Rider__typ, e->H);
1637 }
1638
Texts_Store(Files_Rider * r,ADDRESS * r__typ,Texts_Text T)1639 void Texts_Store (Files_Rider *r, ADDRESS *r__typ, Texts_Text T)
1640 {
1641 Files_Rider r1;
1642 Texts_Run u = NIL, un = NIL;
1643 Texts_Elem e = NIL;
1644 INT32 org, pos, delta, hlen, rlen;
1645 INT8 ecnt, fcnt;
1646 CHAR ch;
1647 INT8 fno;
1648 Texts_FileMsg msg;
1649 Texts_IdentifyMsg iden;
1650 CHAR mods[64][32], procs[64][32];
1651 Texts_FontsFont fnts[32];
1652 CHAR block[1024];
1653 struct Store__39 _s;
1654 _s.ecnt = &ecnt;
1655 _s.msg = &msg;
1656 _s.iden = &iden;
1657 _s.mods = (void*)mods;
1658 _s.procs = (void*)procs;
1659 _s.lnk = Store__39_s;
1660 Store__39_s = &_s;
1661 org = Files_Pos(&*r, r__typ);
1662 msg.id = 1;
1663 msg.r = *r;
1664 Files_WriteLInt(&msg.r, Files_Rider__typ, 0);
1665 u = T->head->next;
1666 pos = 0;
1667 delta = 0;
1668 fcnt = 1;
1669 ecnt = 1;
1670 while (u != T->head) {
1671 if (__ISP(u, Texts_ElemDesc, 1)) {
1672 iden.mod[0] = 0x00;
1673 (*__GUARDP(u, Texts_ElemDesc, 1)->handle)(__GUARDP(u, Texts_ElemDesc, 1), (void*)&iden, Texts_IdentifyMsg__typ);
1674 } else {
1675 iden.mod[0] = 0x01;
1676 }
1677 if (iden.mod[0] != 0x00) {
1678 fnts[__X(fcnt, 32)] = u->fnt;
1679 fno = 1;
1680 while (__STRCMP(fnts[__X(fno, 32)]->name, u->fnt->name) != 0) {
1681 fno += 1;
1682 }
1683 Files_Write(&msg.r, Files_Rider__typ, fno);
1684 if (fno == fcnt) {
1685 fcnt += 1;
1686 Files_WriteString(&msg.r, Files_Rider__typ, u->fnt->name, 32);
1687 }
1688 Files_Write(&msg.r, Files_Rider__typ, u->col);
1689 Files_Write(&msg.r, Files_Rider__typ, u->voff);
1690 }
1691 if (__ISP(u, Texts_PieceDesc, 1)) {
1692 rlen = u->len;
1693 un = u->next;
1694 while ((((((__ISP(un, Texts_PieceDesc, 1) && un->fnt == u->fnt)) && un->col == u->col)) && un->voff == u->voff)) {
1695 rlen += un->len;
1696 un = un->next;
1697 }
1698 Files_WriteLInt(&msg.r, Files_Rider__typ, rlen);
1699 pos += rlen;
1700 u = un;
1701 } else if (iden.mod[0] != 0x00) {
1702 StoreElem__40(&msg.r, Files_Rider__typ, pos, __GUARDP(u, Texts_ElemDesc, 1));
1703 pos += 1;
1704 u = u->next;
1705 } else {
1706 delta += 1;
1707 u = u->next;
1708 }
1709 }
1710 Files_Write(&msg.r, Files_Rider__typ, 0);
1711 Files_WriteLInt(&msg.r, Files_Rider__typ, T->len - delta);
1712 hlen = (Files_Pos(&msg.r, Files_Rider__typ) - org) + 2;
1713 Files_Set(&r1, Files_Rider__typ, Files_Base(&msg.r, Files_Rider__typ), org);
1714 Files_WriteLInt(&r1, Files_Rider__typ, hlen);
1715 u = T->head->next;
1716 while (u != T->head) {
1717 if (__ISP(u, Texts_PieceDesc, 1)) {
1718 if (__ISP(u, Texts_PieceDesc, 1)) {
1719 if ((*(Texts_Piece*)&u)->ascii) {
1720 Files_Set(&r1, Files_Rider__typ, (*(Texts_Piece*)&u)->file, (*(Texts_Piece*)&u)->org);
1721 delta = (*(Texts_Piece*)&u)->len;
1722 while (delta > 0) {
1723 Files_Read(&r1, Files_Rider__typ, (void*)&ch);
1724 delta -= 1;
1725 if (ch == 0x0a) {
1726 Files_Write(&msg.r, Files_Rider__typ, 0x0d);
1727 } else {
1728 Files_Write(&msg.r, Files_Rider__typ, ch);
1729 }
1730 }
1731 } else {
1732 Files_Set(&r1, Files_Rider__typ, (*(Texts_Piece*)&u)->file, (*(Texts_Piece*)&u)->org);
1733 delta = (*(Texts_Piece*)&u)->len;
1734 while (delta > 1024) {
1735 Files_ReadBytes(&r1, Files_Rider__typ, (void*)block, 1024, 1024);
1736 Files_WriteBytes(&msg.r, Files_Rider__typ, (void*)block, 1024, 1024);
1737 delta -= 1024;
1738 }
1739 Files_ReadBytes(&r1, Files_Rider__typ, (void*)block, 1024, delta);
1740 Files_WriteBytes(&msg.r, Files_Rider__typ, (void*)block, 1024, delta);
1741 }
1742 } else __WITHCHK;
1743 } else {
1744 iden.mod[0] = 0x00;
1745 (*__GUARDP(u, Texts_ElemDesc, 1)->handle)(__GUARDP(u, Texts_ElemDesc, 1), (void*)&iden, Texts_IdentifyMsg__typ);
1746 if (iden.mod[0] != 0x00) {
1747 Files_Write(&msg.r, Files_Rider__typ, 0x1c);
1748 }
1749 }
1750 u = u->next;
1751 }
1752 __GUARDEQR(r, r__typ, Files_Rider) = msg.r;
1753 if (T->notify != NIL) {
1754 (*T->notify)(T, 3, 0, 0);
1755 }
1756 Store__39_s = _s.lnk;
1757 }
1758
Texts_Close(Texts_Text T,CHAR * name,ADDRESS name__len)1759 void Texts_Close (Texts_Text T, CHAR *name, ADDRESS name__len)
1760 {
1761 Files_File f = NIL;
1762 Files_Rider r;
1763 INT16 i, res;
1764 CHAR bak[64];
1765 __DUP(name, name__len, CHAR);
1766 f = Files_New(name, name__len);
1767 Files_Set(&r, Files_Rider__typ, f, 0);
1768 Files_Write(&r, Files_Rider__typ, 0xf0);
1769 Files_Write(&r, Files_Rider__typ, 0x01);
1770 Texts_Store(&r, Files_Rider__typ, T);
1771 i = 0;
1772 while (name[__X(i, name__len)] != 0x00) {
1773 i += 1;
1774 }
1775 __COPY(name, bak, 64);
1776 bak[__X(i, 64)] = '.';
1777 bak[__X(i + 1, 64)] = 'B';
1778 bak[__X(i + 2, 64)] = 'a';
1779 bak[__X(i + 3, 64)] = 'k';
1780 bak[__X(i + 4, 64)] = 0x00;
1781 Files_Rename(name, name__len, bak, 64, &res);
1782 Files_Register(f);
1783 __DEL(name);
1784 }
1785
EnumPtrs(void (* P)(void *))1786 static void EnumPtrs(void (*P)(void*))
1787 {
1788 P(Texts_new);
1789 P(Texts_del);
1790 P(Texts_FontsDefault);
1791 }
1792
1793 __TDESC(Texts_FontDesc, 1, 0) = {__TDFLDS("FontDesc", 32), {-8}};
1794 __TDESC(Texts_RunDesc, 1, 3) = {__TDFLDS("RunDesc", 40), {0, 8, 24, -32}};
1795 __TDESC(Texts_PieceDesc, 1, 4) = {__TDFLDS("PieceDesc", 56), {0, 8, 24, 40, -40}};
1796 __TDESC(Texts_ElemMsg, 1, 0) = {__TDFLDS("ElemMsg", 1), {-8}};
1797 __TDESC(Texts_ElemDesc, 1, 4) = {__TDFLDS("ElemDesc", 64), {0, 8, 24, 56, -40}};
1798 __TDESC(Texts_FileMsg, 1, 1) = {__TDFLDS("FileMsg", 32), {16, -16}};
1799 __TDESC(Texts_CopyMsg, 1, 1) = {__TDFLDS("CopyMsg", 8), {0, -16}};
1800 __TDESC(Texts_IdentifyMsg, 1, 0) = {__TDFLDS("IdentifyMsg", 64), {-8}};
1801 __TDESC(Texts_BufDesc, 1, 1) = {__TDFLDS("BufDesc", 16), {8, -16}};
1802 __TDESC(Texts_TextDesc, 1, 2) = {__TDFLDS("TextDesc", 40), {16, 24, -24}};
1803 __TDESC(Texts_Reader, 1, 4) = {__TDFLDS("Reader", 72), {8, 24, 40, 56, -40}};
1804 __TDESC(Texts_Scanner, 1, 4) = {__TDFLDS("Scanner", 168), {8, 24, 40, 56, -40}};
1805 __TDESC(Texts_Writer, 1, 4) = {__TDFLDS("Writer", 56), {0, 8, 32, 48, -40}};
1806 __TDESC(Texts__1, 1, 5) = {__TDFLDS("", 144), {0, 8, 24, 56, 64, -48}};
1807
Texts__init(void)1808 export void *Texts__init(void)
1809 {
1810 __DEFMOD;
1811 __MODULE_IMPORT(Files);
1812 __MODULE_IMPORT(Modules);
1813 __MODULE_IMPORT(Out);
1814 __MODULE_IMPORT(Reals);
1815 __REGMOD("Texts", EnumPtrs);
1816 __INITYP(Texts_FontDesc, Texts_FontDesc, 0);
1817 __INITYP(Texts_RunDesc, Texts_RunDesc, 0);
1818 __INITYP(Texts_PieceDesc, Texts_RunDesc, 1);
1819 __INITYP(Texts_ElemMsg, Texts_ElemMsg, 0);
1820 __INITYP(Texts_ElemDesc, Texts_RunDesc, 1);
1821 __INITYP(Texts_FileMsg, Texts_ElemMsg, 1);
1822 __INITYP(Texts_CopyMsg, Texts_ElemMsg, 1);
1823 __INITYP(Texts_IdentifyMsg, Texts_ElemMsg, 1);
1824 __INITYP(Texts_BufDesc, Texts_BufDesc, 0);
1825 __INITYP(Texts_TextDesc, Texts_TextDesc, 0);
1826 __INITYP(Texts_Reader, Texts_Reader, 0);
1827 __INITYP(Texts_Scanner, Texts_Reader, 1);
1828 __INITYP(Texts_Writer, Texts_Writer, 0);
1829 __INITYP(Texts__1, Texts_ElemDesc, 2);
1830 /* BEGIN */
1831 Texts_del = NIL;
1832 __NEW(Texts_FontsDefault, Texts_FontDesc);
1833 __MOVE("Syntax10.Scn.Fnt", Texts_FontsDefault->name, 17);
1834 __ENDMOD;
1835 }
1836