-
Notifications
You must be signed in to change notification settings - Fork 1
/
crock.c
3117 lines (2938 loc) · 98.4 KB
/
crock.c
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Hullo, Emacs (et al), this is -*-C-*- code. Thus, behave! */
#define VERSION "3.13"
/* meryl.csd.uu.se!/home/ida/guest/kpj/a004/crock.c, 1993-03-22 06:38:13 CET,
kpj
312 Use select() on 4.3BSD systems. */
/* sauron.smilax.zyx.se!C:/usr/local/crock/crock.c 1992-02-05 02:42:46 MET,kpj
311 End of moby update:
| Merged in support for TOPS-20 Sargasso C compiler. */
/* sauron.smilax.zyx.se!C:/usr/local/crock/crock.c 1992-02-05 02:19:04 MET,kpj
310 Change clear screen sequence to $[2J$[H for ANSI devices. */
/* sauron.smilax.zyx.se!C:/usr/local/crock/crock.c 1992-02-05 02:01:23 MET,kpj
309 Merged in edit from diverging version:
| sauron.smilax.zyx.se!D:/usr/src/crock/crock.c 1990-10-13 04:03:35 CET, kpj
| 25 Make this compile with MicroSoft C. Change code to make MSC happy.
| Merge and optimize video fiddling on IBM PC. Less #ifdef's. Handle
| MSC /Za switch gracefully. */
/* sauron.smilax.zyx.se!R:/src/crock/crock.c 1991-10-08 19:44:06 MET, kpj
308 Started including [partial] X11 support. */
/* remo.smilax.zyx.se!C:/kpj/crock.c 1991-08-28 16:29:08 MDT, kpj
307 GNUDOS: An unholy marriage between GNU and MS/PC/DR-DOS.
Cannot use BIOS calls. NARROW is now permanently on for MESSYDOG.
`-n' does nothing on GNUDOS. DVIDEO can be set for GNUDOS. */
/* sauron.smilax.zyx.se!C:/etc/bin/src/crock/crock.c 1991-08-28 14:35:42 MDT
kpj
306 Hack attack ends..
Optimized screen output and cursor movement (need DVIDEO or HASTTYSIZ)
Sargasso-10 and KCC-20 code updated to handle HASTTYSIZ
Can use relative addressing only with OPTIMIZER (need to know where
you are on the screen)
Try to use the `IBM Extended ASCII' for something useful.
Microsoft C does not have sleep(). It also rejects add_str() and
add_character() macros, since their arguments happen to be defined
with #ifdef ... #endif partly.
Variable `T1' optimized away
Argument `-D' sets debugging mode (next argument is file name, or if
not present or starts with `-', use stderr (rather messy)).
Understand UNIX form argument: `-abcd' means `-a -b -c -d', etc.
If debugging, a massive debug output crashes in the debug file
[really should be possible to enable debug on various features, but
that's not included `at this time'].
Moby renaming of rest of variables:
from to from to
---- -- ---- --
Exitt() exitt() BIOSmode bios_mode
Timex() timex() VideoOff video_off
Sleep() zleep() VideoPage video_page
ImageMode() init_world() VideoSeg video_seg
BigNormalMode() restore_world() VideoAttr video_attr
NormalMode() restore_modes() HR hr
Locate() locate() OldH old_hour
real_Locate() real_locate() OldM old_minute
CrockDraw() crock_draw() OldS ols_second
UserX() user_x() Minute minute
Hour hour Second second
Type type Length length
Oldhc old_hpos OldVC old_vpos
Txt i Byte byte
Hpos[] save_hpos[] VPos[] save_vpos[]
HIncr[] h_incr[] VIncr[] v_incr[]
Foo[] hand_char[] Hand[] hand_data[]
SChar[] sec_char[] Cursor cursor
real_h_position real_hpos real_v_position real_vpos
shadow_hpos virt_hpos shadow_vpos virt_vpos
Pr1meMode prime_mode Pr1meSleep prime_sleep
Pr1meKbhit prime_kbhit erasure_ptr eras_ptr
erasure_hpos[] eras_hpos[] erasure_vpos[] eras_vpos[]
hc hpos VC vpos
Bottom() bottom() T quadrant
N slope */
/* sauron.smilax.zyx.se!D:/usr/local/crock/crock.c 1991-08-25 05:21:15 MDT,kpj
305 Hack attack starts.. */
/* sauron.smilax.zyx.se!D:/usr/local/crock/crock.c 1991-08-13 00:30:15 MDT,kpj
304 Compilation option NARROW enables code to set 40 character wide screen
video mode on MS/PC/DR-DOS if `-n' argument specified. Save old mode
and restore it at exit. */
/* sauron.smilax.zyx.se!D:/usr/local/crock/crock.c 1991-08-13 00:16:36 MDT,kpj
303 Display version only when `-v' argument given. */
/* remo.smilax.zyx.se!C:/kpj/crock.c 1991-08-10 18:29:10 MDT, kpj
302 GCC: function parameters are widened:
SHORT (short int) to int
UCHAR (unsigned char) to int
Change: Locate(), dca(), rca(). */
/* sauron.smilax.zyx.se!B:/crock.c 1991-08-07 23:41:56 MDT, kpj
301 Display version if "-v" parameter specified. */
/* sauron.smilax.zyx.se!D:/usr/new/src/crock.c 1991-08-05 00:36:32 MDT, kpj
300 Major munging taking place (version 3.x):
Documentation of compilation switches to file `crock.doc'.
Code from anders@ifi.uio.no removed and is no longer present.
Code from CKN@<some obscure Pr1me somewhere> moved to `crock.pr1'
and #include'd under #ifdef PR1MEC.
Additions: Optimize ANSI sequences. */
/* ======================================================================== */
/* kuling:/us/guest/kpj/crock.c, 4-Aug-91 21:43:45, Edit: kpj@kuling
30 Write a kbhit() for Berkeley systems, using ioctl(), according to the
manual. [It does not work as advertised.] */
/* smaug.smilax.zyx.se!C:/kpj/crock.c 1991-08-03 20:58:16 MDT, kpj
29 Make this compile with GCC port on MS/PC/DR-DOS under #define GNUDOS.
GNUDOS is a Unix system with kbhit(). */
/* sauron.smilax.zyx.se!D:/usr/new/src/crock.c 1991-08-02 22:39:08 MDT, kpj
28 Make this compile with Microsoft C 5.00 under MS/PC/DR-DOS:
- Same capabilities as Turbo C (prototypes, "void", etc)
- Text on "#endif" converted to comments.
- Be explicit about data conversions.
- Cannot use direct video.
- Get rid of cursor during execution.
Turbo C in ANSI mode:
- Keyword "interrupt" is unknown.
#define "interrupt" to nothing ("interrupt" used in <dos.h>)
- Keyword "far" in unknown, no far pointers can be used.
Use peek() and poke() functions instead.
- Register aliases (_AL, _AX, etc) are unknown.
Use int86() instead of direct DOS calls.
- Get rid of cursor during execution, not just #ifdef DVIDEO.
General:
- Bug in ANSI driver fixed.
- `Byte' is USHORT, not char. */
/* sauron.smilax.zyx.se!D:/usr/new/src/crock.c 1991-08-02 22:35:11 MDT, kpj
27 Put cursor at left margin when leaving program in ANSI mode. */
/* emil!/home/emil/guest/kpj/a004/crock.c, 1991-07-44 17:12:52,Edit:emil!kpj
26 SUN-4 has not "const" */
/* emil!/home/emil/guest/kpj/a004/crock.c, 1991-05-33 16:37:44,Edit:emil!kpj
25 Change FUNNYCHR conditional to default off. Variable HC
conflicts with curses/termcap usage, changed to "hc".
Add NOBSP conditional for the situation when cannot use Backspace
to move the cursor in ANSI mode. */
/* sauron.smilax.zyx.se!D:/usr/src/crock/crock.c 1990-08-15 09.42.20 CST, kpj
24 Added direct video memory access for Turbo C, under #ifdef DVIDEO.
Somewhat faster. */
/* sauron.smilax.zyx.se!D:/usr/src/crock/crock.c 1990-08-15 08.58.25 CST, kpj
23 Fixed bug from edit #19: SHORT cannot be #define'd as char, since it
char may or may not be unsigned. #define SHORT as short. */
/* sauron.smilax.zyx.se!D:/usr/src/crock/crock.c 1990-08-15 08.27.22 CST, kpj
22 Handle CTRL/BREAK condition as normal exit, under #ifdef CTRLBRK */
/* sauron.smilax.zyx.se!D:/usr/src/crock/crock.c 1990-08-14 21.18.52 CST, kpj
21 Added prototypes and header files. Don't expect char to be (un)signed.
No nested comments, please. */
/* Betong.SUB.SU.SE!C:\KPJ\A004\CROCK.C 1989-08-09 15:28:03 kpj
20 Bug in reversed initial clock picture. */
/* sauron.smilax.zyx.se!D:\PIKLUCKA\CROCK\CROCK.C 1989-05-22 19:54:58 kpj
19 Make it faster by using SHORT where possible. On MS-DOS (aka
PC-DOS) the sleep() just loops until the time have changed; so
in order to not lose a second here and there we just don't "sleep"
on these single-process systems. Sigh, what a lossage! */
/* sauron.smilax.zyx.se!D:\PIKLUCKA\CROCK\CROCK.C 1989-05-20 18:02:07 kpj
18 Merged in Pr1me hacks by ckn under #ifdef PR1MEC
[Pr1me C hacks by CKN (some guy living in Farsta, Sweden)]
*/
/* AIDA::PS:<SLASK>CROCK.C.4 28-Apr-89 07:35:52 LEBEL.DEMON
17 Make it run under KCC-20 compiler (again). "\8" was not understood by
KCC. Use "\b" instead. */
/* sauron.smilax.zyx.se!D:\PIKLUCKA\CROCK\CROCK.C 1989-04-21 22:48:31 EET kpj
16 Merge in code for reversed clock: REVCLK conditional compilation
flag adds in code to reverse clock when "-b" parameter given. The
terminal code: AMIGA and IBM-PC have ANSI drivers. For all the rest,
put the code in ANSI conditionals, and merge in all the drivers for
various terminals (from edits 1..7): EL1521, TEK4025, VK100 (GIGI). */
/* suadb.dsv.su.se/guest/stud/ar/crock.c 21-Apr-1989 19:00:09 EET, edit by ar
15 Make this work under VAX BSD 4.2 C compiler. */
/* sauron.smilax.zyx.se!D:\PIKLUCKA\CROCK\CROCK.C 1989-04-20 01:14:50 GMT+0100
kpj
14 Optimize code. */
/* sauron.smilax.zyx.se!D:\PIKLUCKA\CROCK\CROCK.C 1989-04-17 23:32:16 GMT+0100
kpj
13 Add support for BSD 4.2 Curses package. It looks awful, though. */
/* smilax.smilax.zyx.se!Crock:crock.c 1989-04-15 19:52:34 GMT+0100 kpj
12 Amiga Aztec/Manx C compiler 3.4a has a bug which makes it hate any
"const" in the code, and the pre-processor has the idea that it is
an error to redefine "const" to anything. Sigh. Define ESC.
There is a Draw() and SetSignal() procedures in the Manx/Aztec library
so we have to rename our procedures to CrockDraw() and CrockSignal()
to avoid ambiguity. */
/* Smertz!D:\PIKLUCKA\CROCK\CROCK.C 1989-04-15 14:37:15 GMT, kpj
11 Edit 10 is for SUN4, actually. Things are done differently in other
UNIX system. Parameterize the code. */
/* ifi.uio.no!/svarte/home/anders/c/crock.c, Tue Apr 11 00:55:21 1989
edit by: anders */
/* 10 Up an running on UNIX */
/* Smertz!D:\PIKLUCKA\CROCK\CROCK.C 1989-04-10 21:22:04 kpj
9 Add DCROCK option, to display time in digital "hh:mm:ss" format too */
/* Betong!C:\KPJ\A004\CROCK.C 1989-04-10 17:43:19 kpj
8 Make it somewhat faster. */
/* Betong!C:\KPJ\A004\CROCK.C 1989-04-10 13:17:19 kpj
7 Make it work on IBM-PC using Turbo C (rather UNIX-like).
The UNIX interface not fully ready yet, though. */
/* Athena::Ps:<KPJ-Jaakkola.A004>Crock.C.8 880120-0928,KPJ-Jaakkola */
/* 6 Make program run on TOPS-20 using KCC compiler. */
/* Oden::DSKD:CROCK.C<10,50,A004> 1988-01-19 16:14:08, KPJ @ IBM <10,50> */
/* 5 Sargasso-10 code is excessively slow, so we use extremely kludgey
assembly hacks and better C code to make it faster. */
/* Oden::DSKD:CROCK.C<10,50,A004> 1988-01-18 21:52:49, KPJ @ GR\N <10,50> */
/* 4 MSTIME returns milliseconds, not 1/100 of seconds. */
/* Oden::DSKD:CROCK.C<10,50,A004> 1988-01-18 17:33:49, KPJ @ IBM <10,50> */
/* 3 Converted more from MIDAS version, which is more C compatible. */
/* Oden::DSKD:CROCK.C<10,50,A004> 1988-01-16 13:03:11, KPJ @ H.HOLE <10,50> */
/* 2 First somewhat working Sargasso-10 version. */
/* Oden::DSKD:CROCK.C<10,50,A004> 1988-01-14 16:12:12, KPJ @ IBM <10,50> */
/* 1 First attempt in converting from AmigaBasic to C. */
/* ====================================================================
A BASIC version for AMIGA and MS-Dog (both extremely slow) by KPJ.
MIDAS (for Bottoms-10) version by KPJ.
Original MIDAS (for ITS) version edit history:
Original program hacked up by GLS
10X/20X version hacked by KLH.
Some 10X modifications done by EAK.
==================================================================== */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Shorthand for MS/PC/DR-DOS compilers. */
#ifdef __MSDOS__
#define MESSYDOG
#endif
#ifdef MSDOS
#define MESSYDOG
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* 0. NOTE: To make this code compile with the Sargasso C compiler */
/* on the *old* Tops-10 operating system, NO preprocessor */
/* lines herein may have comments on them, and NO files */
/* can be #include'd WITHOUT APPROPRIATE #ifdef'S. This */
/* is true even for <stdio.h>, which is <stdio.HDR> with */
/* Sargasso-10 C compiler, a moby loser. */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* 1. Here we define what capabilities our *system* has. We do it to */
/* have less #ifdef's and #endif's in the rest of the program. */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef SARG10
/* Sargasso-10 C compiler: has nothing, use Tops-10 coding. */
/* [306] Use .TRMOP(.TOWID and .TOPSZ) to get screen size. */
#define HASUSERX
#define HASTTYSIZ
#endif
#ifdef SARG20
/* Sargasso-20 C compiler: has nothing, use TOPS-20 coding. */
#define HASUSERX
#define HASTTYSIZ
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef KCC
/* KCC C compiler: has setbuf(), use TOPS-20 "jsys" package for rest */
/* [306] has code to get terminal width and height. */
#define HASUSERX
#define HASSETBUF
#define HASTTYSIZ
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef __TURBOC__
/* Turbo C on MS/PC/DR-DOS (OS/2 not supported as yet) */
/* Has: Un*x format time(), quiet exit(), setbuf() and kbhit() */
/* We don't use any signals, it's too complicated. */
/* [306] has code to deduce terminal width and height (from video mode) */
#define HASTIME
#define HASEXIT
#define HASSETBUF
#define HASKBHIT
#define HASSLEEP
#define HASTTYSIZ
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef PR1MEC
/* Prime C: no setbuf(), various Prime specific code in `crock.pr1' */
/* [306] currently no code to get terminal width and height. */
#define HASUSERX
#include "crock.pr1"
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef AMIGA
/* Amiga: either Manx/Aztec C or Lattice C compiler. */
/* Manx/Aztec is the default. Lattice C compiler is untested. */
#ifndef MANX
#ifndef LATTICE
#define MANX
#endif
#endif
/* Amiga: Manx/Aztec C compiler: has setbuf(), time(), quiet exit() */
/* No kbhit(), signal(), sleep() */
/* [306] currently no code to get screen width and height. */
#ifdef MANX
#define HASSETBUF
#define HASTIME
#define HASEXIT
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef X11
/* ... stuff to define X11 environment ... */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Convert various Un*x systems into the `generic' Un*x version to make */
/* the code later somewhat less burdened with #ifdef's. */
#ifdef unix
#define UNIX /* Handle this anomaly */
#endif
#ifdef SUN4
#define UNIX /* SUN-4 is a Un*x system */
#endif
#ifdef BSD42
#define UNIX /* BSD 4.2 is a Un*x system */
#define BSD /* [312] */
#endif
#ifdef X11
#define HASUSERX /* [313] We use X Window System I/O. */
#endif
#ifdef BSD43
/* [312] 4.3BSD is a Un*x system */
#define UNIX /* [312] */
#define BSD /* [312] */
#define HASUSERX /* [312] */
#define HASVOID /* [312] has `void' data type */
#endif /* [312] */
#ifdef GNUDOS
/* GNU is like Un*x. */
/* DJ's GNU cc port to MS/PC/DR-DOS. */
/* Has: everything the generic Un*x has, and kbhit(). */
#define UNIX
#define HASKBHIT
#define HASTTYSIZ
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef UNIX
/* Generic Un*x: signal(), time(), quiet exit(), setbuf(), sleep() */
/* No kbhit(), generally. */
/* [306] Currently no code to get screen width and height. */
#define HASSIGNAL
#define HASTIME
#define HASEXIT
#define HASSETBUF
#ifdef BSD43
/* [312] 4.3BSD uses select() instead of sleep(). */
#endif
#ifndef BSD43
#define HASSLEEP
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef MSDOS
/* Microsoft C on MS/PC/DR-DOS (OS/2 not supported as yet) */
/* Has: Un*x format time(), quiet exit(), setbuf() and kbhit() */
/* We don't use any signals, it's too complicated. */
/* Like Turbo C, except not ISO C compatible (no __STDC__ defined) */
/* [306] has code to deduce screen width and height (from video mode) */
#define HASTIME
#define HASEXIT
#define HASSETBUF
#define HASKBHIT
#define HASSLEEP
#define HASTTYSIZ
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef HASKBHIT
/* If we have the kbhit() function, we also have user_x() function. */
#define HASUSERX
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Make sure we can exit the program. */
#ifndef HASEXIT
#ifndef KCC
#ifndef SARG20
#ifndef SARG10
"error: no code in exitt() -- cannot exit program"; /* bug */
#endif
#endif
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Make sure we can get current time (hours, minutes, seconds). */
#ifndef HASTIME
#ifndef KCC
#ifndef SARG20
#ifndef SARG10
"error: no code in timex() -- cannot get time"; /* bug */
#endif
#endif
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Make sure we can sleep one second. */
#ifndef SARG10
#ifndef SARG20
#ifndef KCC /* TOPS-20 special code does DISMS% */
#ifndef HASSLEEP /* sleep() */
#ifndef PR1MEC /* Prime code has own sleep() */
#ifndef AMIGA /* AMIGA uses Delay() */
#ifndef BSD43 /* [312] 4.3BSD uses select() */
"error: no code in zleep() -- cannot sleep 1 second"; /* bug */
#endif /* [312] */
#endif
#endif
#endif
#endif
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Make sure we can detect user input. */
#ifdef HASUSERX
#ifndef BSD43
#ifndef PR1MEC
#ifndef HASKBHIT
#ifndef KCC
#ifndef SARG20
#ifndef SARG10
"error: no code in user_x() -- cannot detect input"; /* bug */
#endif
#endif
#endif
#endif
#endif
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Check if main() has arguments. */
#ifdef DCROCK
#define ARGV
#else
#ifdef REVCLK
#define ARGV
#else
#ifdef VERSION
#define ARGV
#else
#ifdef NARROW /* [304] */
#define ARGV /* [304] */
#else
#ifdef X11 /* [313] */
#define ARGV /* [313] */
#else /* [313] */
/* don't #define ARGV */
#endif /* [313] */
#endif /* [304] */
#endif
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Check if can get (terminal) screen width (in number of characters) */
/* and height (in lines). We need this to use the OPTIMIZER code, if */
/* not DVIDEO is set. */
#ifndef DVIDEO
#ifndef HASTTYSIZ
#ifdef OPTIMIZER
#undef OPTIMIZER
"error(OPTIMIZER): no code to get terminal screen size";
#endif
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef MSDOS
/* Microsoft C 5.00 and later */
#define sleep(x)
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* 3. The `crock' program can use various types of terminal equipment */
/* and we define here what kind of terminal driver (if any) we are */
/* to generate code for. See the file `crock.doc' for details. */
#ifdef X11
/* `X Window System, Version 11' package has own drivers. */
#define HASDRV
#endif
#ifdef CURSES
/* The `curses' package (requires `curses' and `termcap' packages). */
#define HASDRV
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Various forms of ANSI compatible terminal drivers supported. */
#ifdef VT100
/* VT100: DIGITAL VT100 terminal. */
#define ANSI
#endif
/* .................................................................... */
#ifdef VK100
/* VK100: DIGITAL VK100 (GIGI) terminal. */
#define ANSI
#endif
/* .................................................................... */
#ifdef AMIGA
/* AMIGA: Commodore AMIGA personal computer. */
#define ANSI
#endif
/* .................................................................... */
/* IBM Personal Computer and clones (and GNUDOS). */
/* If not DVIDEO (direct video memory write) enabled, we default to an */
/* ANSI.SYS driver. This has an impact to how the backup store of the */
/* optimized screen output will be implemented. DVIDEO enables us to */
/* let the hardware be our backup store: the video RAM. */
#ifdef DVIDEO
/* Direct video memory writes. */
#define HASDRV
#else
/* Assume ANSI driver loaded. */
#ifdef __TURBOC__
#define ANSI
#endif
#ifdef MSDOS
#define ANSI
#endif
#ifdef GNUDOS
#define ANSI
#endif
#endif
#ifdef ANSI
#define TRMNAM "ANSI (e.g. VT100 or VK100/GIGI)"
#define TRMTYP "ANSI"
#define HASDRV
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Tektronix 4025 terminal driver. */
/* Commands start with a `command character' and different sites have */
/* different ones, so we parametrize it: TEKCHR (CTRL/Backslash by */
/* default). */
#ifdef TE4025
#define TEK425
#endif
#ifdef TEK425
#define TRMNAM "Tektronix 4025"
#define TRMTYP "TE4025"
#define HASDRV
#ifndef TEKCHR
#define TEKCHR '\034'
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Elite 1520 or Elite 1521. */
#ifdef EL1520
#define EL1521
#endif
#ifdef EL1521
#define HASDRV
#define TRMNAM "Elite 1520/1521"
#define TRMTYP "EL1521"
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* If no terminal driver defined, no terminal driver code generated. */
#ifndef HASDRV
"error: no terminal driver specified"; /* generate an error */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* 4. System dependent definitions and header files. */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifndef SARG10
#ifndef SARG20
#include <stdio.h> /* Loaded by all, except Sargasso-10 (sigh..) */
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef SARG10
/* Sargasso-10 is a total loser */
#include <stdio.HDR>
/* Make Un*x-flavored I/O on Bottoms-10 */
#define _UNIXCON
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef SARG20
/* Sargasso-20 is a total loser, too */
#include <TOPS20.HDR>
#define _UNIXCON
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef KCC
#include <jsys.h> /* KCC on TOPS-20: use `jsys()' system calls */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef GNUDOS
#include <pc.h> /* DJ's GCC port: Declare kbhit() */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef SUN4
#include <sys/types.h> /* Declare time_t, etc. */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef BSD
/* [412] BSD of some kind */
#ifdef LINUX
#include <linux/types.h>
#define _SYS_TYPES_H
#include <bsd/sgtty.h>
#else
#include <sys/types.h> /* Declare time_t, etc. */
#include <sgtty.h> /* Declare FIONREAD, etc. */
#endif
#endif
#ifdef BSD43
#include <sys/time.h> /* [412] Declare select() */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef __STDC__
/* ISO C compilers: */
#include <stdlib.h> /* Declare exit(), etc. */
#include <string.h> /* Declare strcmp(), etc. */
#ifdef __TURBOC__ /* (Turbo C in ISO mode:) */
#define interrupt /* Disable "interrupt" */
#include <dos.h> /* Declare inregs, outregs, etc. */
#include <conio.h> /* Declare kbhit(), etc. */
#define _AHin inregs.h.ah
#define _ALin inregs.h.al /* [304] */
#define _AXin inregs.x.ax
#define _BHin inregs.h.bh
#define _CHin inregs.h.ch
#define _CLin inregs.h.cl
#define _CXin inregs.x.cx
#define _DHin inregs.h.dh
#define _DLin inregs.h.dl
#define _AHout outregs.h.ah
#define _ALout outregs.h.al /* [304] */
#define _BHout outregs.h.bh
#define _CHout outregs.h.ch
#define _CXout outregs.x.cx
#define _DHout outregs.h.dh
#define _DLout outregs.h.dl
#define _int(x) int86(x,&inregs,&outregs)
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef __TURBOC__
#ifndef __STDC__ /* (Turbo C not in ISO mode:) */
#include <dos.h> /* Declare inregs, outregs, etc. */
#include <conio.h> /* Declare kbhit(), etc. */
#include <stdlib.h> /* Declare exit(), etc. */
#include <string.h> /* Declare strcmp(), etc. */
#define _AHin _AH
#define _ALin _AL /* [304] */
#define _AHout _AH
#define _ALout _AL /* [304] */
#define _AXin _AX
#define _BHin _BH
#define _BHout _BH
#define _CHin _CH
#define _CHout _CH
#define _CLin _CL
#define _CXin _CX
#define _CXout _CX
#define _DHin _DH
#define _DHout _DH
#define _DLin _DL
#define _DLout _DL
#define _int(x) geninterrupt(x)
#endif
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef MSDOS
/* Microsoft C: */
#include <conio.h> /* Declare kbhit(), etc. */
#include <stdlib.h> /* Declare exit(), etc. */
#include <string.h> /* Declare strcmp(), etc. */
#include <dos.h> /* Declare inregs, outregs, etc. */
#define _AHin inregs.h.ah
#define _ALin inregs.h.al /* [304] */
#define _AXin inregs.x.ax
#define _BHin inregs.h.bh
#define _CHin inregs.h.ch
#define _CLin inregs.h.cl
#define _CXin inregs.x.cx
#define _DHin inregs.h.dh
#define _DLin inregs.h.dl
#define _AHout outregs.h.ah
#define _ALout outregs.h.al /* [304] */
#define _BHout outregs.h.bh
#define _CHout outregs.h.ch
#define _CXout outregs.x.cx
#define _DHout outregs.h.dh
#define _DLout outregs.h.dl
#define _int(x) int86(x,&inregs,&outregs)
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef X11
#include <X11/Xlib.h> /* [313] declare interface functions */
#ifdef ISONESS /* [313] */
#include <stdlib.h> /* [313] declare getenv() */
#else /* [313] */
extern char* getenv(); /* [313] we need these */
#endif
#include <pwd.h> /* [313] declare getpwuid() */
#ifdef NeedFunctionPrototypes /* [313] need function prototypes? */
#define ISONESS /* [313] yes, turn on ISOness */
#endif /* [313] */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef HASSIGNAL
#include <signal.h> /* Declare signal(), etc. */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef HASTIME
#include <time.h> /* Declare time(), etc. */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef CURSES
#include <curses.h> /* Declare `curses' package. */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* See if FUNNYCHR is not necessary: MESSYDOG uses "IBM Extended ASCII" */
/* and AMIGA uses ISO 8859-1 character sets. */
#ifdef GNUDOS
#undef FUNNYCHR
#endif
#ifdef __MSDOS__
#undef FUNNYCHR /* MS/PC/DR-DOS */
#endif
#ifdef MSDOS
#undef FUNNYCHR /* MS/PC/DR-DOS */
#endif
#ifdef AMIGA
#undef FUNNYCHR /* AMIGA */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* General data type declarations. */
#define SHORT short int
#define UCHAR unsigned char
#define ANYTHING 42
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* See if want rca() routine. */
/* See if want dca() routine. */
#ifdef ANSI
#ifdef OPTIMIZER
#define WANT_RCA
#define MAXRIGHT 4
#endif
#define OFFSET 1
#define WANT_DCA
#endif
#ifdef TEK425
#ifdef OPTIMIZER
#define WANT_RCA
#define MAXRIGHT 6
#endif
#define WANT_DCA
#endif
#ifdef CURSES
#undef WANT_RCA
#undef WANT_DCA
#endif
#ifdef DVIDEO
#undef WANT_RCA
#undef WANT_DCA
#endif
#ifdef EL1521
#undef WANT_RCA
#define WANT_DCA
#endif
#ifndef OFFSET
#define OFFSET 0
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* 5. Prototypes. */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifndef ISONESS
/* [313] need function prototypes? */
#ifdef __STDC__
#define ISONESS /* ISO C has prototypes. */
#endif
#ifdef MESSYDOG
#define ISONESS /* Microsoft C and Turbo C, too */
#endif
#ifdef GCC
#define ISONESS /* GNU cc */
#endif
#endif
#ifdef ISONESS
#define VOID void
#define VOIDARG void
#ifndef CONST
#define CONST const
#endif
#define SIGNAL void
#define AND ,
#define DEFUN(F, L, P) F(P)
#define EXFUN(F, P) F P
#else
#ifdef HASVOID
#ifndef VOID
#define VOID void
#endif
#else
#define VOID int
#endif
#define VOIDARG /* nothing */
#define CONST /* nothing */
#ifndef SIGNAL
/* [312] */
#define SIGNAL int
#endif
#define AND ;
#define DEFUN(F, L, P) F L P ;
#define EXFUN(F, P) F()
#endif
VOID EXFUN(exitt,(VOIDARG)); /* non-printing process termin. */
VOID EXFUN(timex,(SHORT *, SHORT *, SHORT *)); /* wall-clock time */
VOID EXFUN(zleep,(VOIDARG)); /* sleep one second */
VOID EXFUN(init_world,(VOIDARG)); /* initialize world */
VOID EXFUN(restore_world,(VOIDARG)); /* [306] restore everything */
VOID EXFUN(restore_modes,(VOIDARG)); /* restore original modes */
SIGNAL EXFUN(doquit,(VOIDARG)); /* [312] normal exit */
#ifdef WANT_DCA
VOID EXFUN(dca,(int, int)); /* [302] direct cursor addr.g */
#endif
#ifdef WANT_RCA
VOID EXFUN(rca,(int, int)); /* [302] relative screen move */
#endif
#ifdef OPTIMIZER
#define INTERFACE
#endif
#ifndef CURSES
#define INTERFACE
#endif
#ifdef X11
#define INTERFACE /* [313] Use real_clear(), etc. routines. */
#undef OPTIMIZER /* [313] No optimizer code. */
#undef CURSES /* [313] No curses. */
#undef DVIDEO /* [313] No direct video access. */
#endif
#ifdef CURSES
#ifdef OPTIMIZER
int EXFUN(backup_store,(int,int)); /* [306] read backup store */
#define real_addch(x) addch(x)
VOID EXFUN(locate,(int,int)); /* [306] interface routine to move() */
VOID EXFUN(add_str,(char *)); /* [306] interface routine to addstr() */
VOID EXFUN(real_clear,(VOIDARG)); /* [306] interface routine to clear() */
VOID EXFUN(add_character,(int));/* [306] interface routine to addch() */
VOID EXFUN(refresh_screen,(VOIDARG)); /* [306] interface routine to refresh()*/
VOID EXFUN(print_word,(char *,SHORT)); /* [306] interface to printw() */
#else
/* not OPTIMIZER */
#define add_str addstr
#define locate(x,y) move((x)-1,(y)-1)
#define real_clear() clear()
#define add_character addch
#define refresh_screen() refresh()
#define print_word printw
#endif
/* not OPTIMIZER */
#else
/* not CURSES */
#ifdef OPTIMIZER
int EXFUN(backup_store,(int,int)); /* [306] read backup store */
int EXFUN(add_erase,(int,int)); /* [306] add erasure table entry */
VOID EXFUN(del_erase,(int)); /* [306] delete erasure table entry */
#ifdef DVIDEO
VOID EXFUN(real_addch,(int)); /* [306] write character to screen */
#else
#define real_addch putchar
#endif
VOID EXFUN(add_str,(char *)); /* [306] write string at cursor */
VOID EXFUN(add_character,(int)); /* [306] write character at cursor */
VOID EXFUN(refresh_screen,(VOIDARG)); /* [306] refresh screen */
VOID EXFUN(print_word,(char *,int)); /* [306] format at cursor */
/* locate(): see below */ /* [306] virtual cursor movement */
VOID EXFUN(real_locate,(int,int)); /* [306] physical cursor movement */
#else
/* not OPTIMIZER */
#ifdef X11
VOID EXFUN(add_character,(int));/* [313] We use these to do the I/O. */
VOID EXFUN(add_str,(char *)); /* [313] . . . */
#else
#ifdef MSDOS
VOID EXFUN(add_character,(int)) /* [306] Microsoft C barfs on macro */
VOID EXFUN(add_str,(char *)); /* [306] . . . */
#else
#define add_str(x) printf("%s",x)
#define add_character putchar
#endif
#endif
#define refresh_screen()
#define print_word printf
#define locate real_locate
#endif
VOID EXFUN(locate,(int,int)); /* [306] virtual cursor movement */
VOID EXFUN(real_clear,(VOIDARG));/* [306] clear screen, handle optimizer */
#endif
VOID EXFUN(crock_draw,(VOIDARG)); /* super-hairy hand drawer */
#ifdef HASUSERX
int EXFUN(user_x,(VOIDARG)); /* user input checker */
#endif
VOID EXFUN(begin,(VOIDARG)); /* initialize, paint clock */
#ifdef ARGV
char *progname; /* program name */
VOID EXFUN(main,(int, char*[])); /* reversed clock: parameters */
#else
VOID EXFUN(main,(VOIDARG)); /* normal clock: no parameters */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* 6. System dependent variable area. */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef SARG20
/* TOPS-20 stuff: */
int ccoc1; /* CCOC, word 1 */
int ccoc2; /* CCOC, word 2 */
#endif
#ifdef KCC
/* TOPS-20 stuff: */
#ifndef OPTIMIZER
int te_width; /* [306] Terminal width */
#endif
int ac[5]; /* jsys() ackumulators: AC 1 .. 5 */
int ccoc1; /* CCOC, word 1 */
int ccoc2; /* CCOC, word 2 */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef GNUDOS
int te_width; /* [307] screen width */
int video_off; /* [307] video memory address offset */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifdef MESSYDOG
/* BIOS calls stuff: */
#ifdef MSDOS
union REGS inregs; /* input registers to int86() */
union REGS outregs; /* output registers to int86() */
#endif
#ifdef __STDC__
union REGS inregs; /* input registers to int86() */
union REGS outregs; /* output registers to int86() */
#endif
unsigned char oldmode; /* [306] old video mode */
#ifdef NARROW /* [304] */
int bios_mode; /* [304] current BIOS video mode */
#else /* [304] */
#ifdef DVIDEO /* [304] */
int bios_mode; /* [304] current BIOS video mode */
#endif /* [304] */
#endif /* [304] */
#ifdef DVIDEO /* (direct video memory access:) */
int video_off; /* [306] video memory address offset */
int video_seg; /* video memory address segment part */
#endif
SHORT video_page; /* video page */
unsigned int cursor; /* cursor start,,stop */
SHORT video_attr; /* video attributes to use */
#endif
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */