-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzwto.pas
461 lines (429 loc) · 10 KB
/
zwto.pas
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
unit zwto;
interface
var erg,erga,zeigp:array[1..12] of byte;
dateinam:string;
tlang:word;
fn:byte;
const zazto:array[1..12]of string[3]=('C ','CIS','D ','ES ','E ','F ',
'FIS','G ','GIS','A ','B ','H ');
zhoer:array[1..12]of word=(262,277,294,311,330,349,370,392,415,
440,466,493);
function zeit :word;
function dbk :boolean;
procedure hoer (x,y:word;vv:boolean);
procedure tonds (x,y,th:word;zeich:boolean);
procedure darstell12t (x,y:word);
procedure eingabe12t (x,y:word;var ps:word);
procedure persausw (var x,y:word);
function interpret (var wv:byte):byte;
procedure allmogl (wv:word);
procedure umkehrung;
procedure zahl (wv:byte);
procedure perspek;
implementation
uses crt,saa12t,graph,dos;
function zeit;
var h,m,s,hs:word;
begin
gettime (h,m,s,hs);
zeit:=((h*60*+m)*60+s)*100+hs;
end;
function dbk;
var hv:word;
begin
repeat mausles;until not maus.lt;
hv:=zeit;
repeat mausles;until(zeit-hv>10)or maus.lt;
dbk:=maus.lt;
end;
procedure hoer;
var i,a:byte;
verlschl:boolean;
z:word;
begin
if vv then i:=1 else i:=12;
a:=i;verlschl:=false;
repeat;
sound(zhoer[erg[i]]);
z:=zeit;
mausanaus(false);
if i<>a then bar(x-23+a*24,y+1,x-1+a*24,y+3);
setfillstyle(1,f3);
bar(x-23+i*24,y+1,x-1+i*24,y+3);
mausanaus(true);
setfillstyle(0,0);
a:=i;
if vv then
if i=12 then verlschl:=true else i:=i+1
else if i=1 then verlschl:=true else i:=i-1;
mausles;
while zeit-z<tlang do;
until verlschl or maus.rt or(keypressed and(readkey=#27));
nosound;
mausanaus(false);
bar(x-23+a*24,y+1,x-1+a*24,y+3);
mausanaus(true);
end;
procedure auflz(x,y:word);
begin
line(x,y-3,x,y-2);
line(x+3,y+2,x+3,y+3);
rectangle(x,y-1,x+3,y+1);
end;
procedure kreuz(x,y:word);
begin
line(x,y-3,x,y+3);
line(x-1,y+1,x+4,y+1);
line(x+3,y-3,x+3,y+3);
line(x-1,y-1,x+4,y-1);
end;
procedure be(x,y:word);
begin
line(x,y-3,x,y+1);
arc(x,y,270,90,2);
end;
procedure tonds;
var y2:word;
begin
if zeich then begin
setcolor(fv);setfillstyle(1,fv);
end else begin
setcolor(fh);setfillstyle(0,0);
end;
case th of
1:begin y2:=20;auflz(x+2,y+y2);end;
2:begin y2:=20;kreuz(x+2,y+y2);end;
3:begin y2:=18;auflz(x+2,y+y2);end;
4:begin y2:=16;be(x+2,y+y2);end;
5:begin y2:=16;auflz(x+2,y+y2);end;
6:begin y2:=14;auflz(x+2,y+y2);end;
7:begin y2:=14;kreuz(x+2,y+y2);end;
8:begin y2:=12;auflz(x+2,y+y2);end;
9:begin y2:=12;kreuz(x+2,y+y2);end;
10:begin y2:=10;auflz(x+2,y+y2);end;
11:begin y2:=8;be(x+2,y+y2);end;
12:begin y2:=8;auflz(x+2,y+y2);end;
end;
fillellipse(x+12,y+y2,3,2);
if zeich and(th<3)then line(x+8,y+y2-(y2 mod 4),x+16,y+y2-(y2 mod 4));
if not zeich then begin
if th<3 then begin
setcolor(fh);
line(x+8,y+y2-(y2 mod 4),x+16,y+y2-(y2 mod 4));
end
else begin
setcolor(fn);
line(x+2,y+y2-(y2 mod 4),x+15,y+y2-(y2 mod 4));
end;
setcolor(fn);
if th>5 then line(x+2,y+y2-(y2 mod 4)+4,x+15,y+y2-(y2 mod 4)+4);
end;
setcolor(fv);setfillstyle(0,0);
end;
procedure darstell12t;
var i:byte;
begin
setcolor(fn);
mausanaus(false);
for i:=0 to 4 do line(x+1,y+i*4,x+287,y+i*4);
for i:=0 to 12 do begin
setcolor(fn);
line(x+i*24,y,x+i*24,y+16);
if i>0 then tonds(x+i*24-22,y,erg[i],true);
end;
mausanaus(true);
end;
procedure eingabe12t;
var th,tha,psa:byte;
verlschl:boolean;
begin
erga:=erg;verlschl:=false;fehler:=false;
darstell12t(x,y);
if ps<1 then ps:=1;
if ps>12 then ps:=12;
th:=erg[ps];tha:=th;psa:=ps;
setfillstyle(1,f3);
mausanaus(false);
bar(x+ps*24-23,y+1,x+ps*24-1,y+3);
mausanaus(true);
setfillstyle(0,0);
repeat
if th<1 then th:=12;
if th>12 then th:=1;
if ps<1 then ps:=1;
if ps>12 then ps:=12;
if(tha<>th)and(psa=ps)then begin
mausanaus(false);
tonds(x+ps*24-22,y,tha,false);
tonds(x+ps*24-22,y,th,true);
mausanaus(true);
tha:=th;
end;
if psa<>ps then begin
erg[psa]:=th;
th:=erg[ps];
setfillstyle(1,f3);
mausanaus(false);
bar(x+ps*24-23,y+1,x+ps*24-1,y+3);
setfillstyle(0,0);
bar(x+psa*24-23,y+1,x+psa*24-1,y+3);
mausanaus(true);
psa:=ps;tha:=th;
end;
if keypressed then begin
case readkey of
#0:case readkey of
#60:begin
mausanaus(false);
bar(x+ps*24-23,y+1,x+ps*24-1,y+3);
mausanaus(true);
erg[ps]:=th;
hoer(x,y,true);
setfillstyle(1,f3);
mausanaus(false);
bar(x+ps*24-23,y+1,x+ps*24-1,y+3);
mausanaus(true);
setfillstyle(0,0);
end;
#71:ps:=1;
#72:th:=th+1;
#75:ps:=ps-1;
#77:ps:=ps+1;
#79:ps:=12;
#80:th:=th-1;
end;
#13:verlschl:=true;
#27:begin erg:=erga;fehler:=true;verlschl:=true;end;
end;
end
else begin
Mausles;
if maus.lt and mausber(x,y,x+288,y+20)then
ps:=trunc((maus.x-x)/24)+1
else if maus.t then verlschl:=true;
end;
until verlschl;
mausanaus(false);
bar(x+psa*24-23,y+1,x+psa*24-1,y+3);
mausanaus(true);
setcolor(fv);
if not fehler then erg[psa]:=th;
end;
function interpret;
var i:byte;
inte:array[1..3]of record
w:byte;
r:boolean;
end;
verlschl:boolean;
begin
for i:=1 to 3 do begin
inte[i].w:=12+erg[i]-erg[i+1];
if inte[i].w>11 then inte[i].w:=inte[i].w-12;
if inte[i].w>6 then begin
inte[i].w:=12-inte[i].w;
inte[i].r:=true;
end else inte[i].r:=false;
end;
i:=1;verlschl:=false;wv:=0;
repeat
if(inte[1].w=5)then begin
verlschl:=true;wv:=1;
end
else if(inte[2].w<>0)and(inte[1].r=inte[2].r)and(((inte[1].w=3)and(inte[2].w=4))
or((inte[1].w=4)and(inte[2].w=3)))then begin
verlschl:=true;wv:=2;
end
else if(inte[3].w<>0)and(inte[1].w=inte[2].w)and(inte[2].w=inte[3].w)then begin
verlschl:=true;wv:=3;
end
else wv:=0;
i:=i+1;
inte[1]:=inte[2];inte[2]:=inte[3];
if i<10 then inte[3].w:=12+erg[i+2]-erg[i+3] else inte[3].w:=0;
inte[3].r:=inte[3].w>11;
if inte[3].r then inte[3].w:=inte[3].w-12;
if inte[3].w>6 then begin
inte[3].w:=12-inte[3].w;
inte[3].r:=true;
end else inte[3].r:=false;
until verlschl or (i>11);
if verlschl then interpret:=i-1
else interpret:=0;
end;
procedure allmogl;
var st,i,sta:byte;
wvmogl:longint;
dat:text;
s:string[8];
verlschl,such:boolean;
inte:array[1..3]of byte;
begin
wvmogl:=0;such:=wv=0;
mausanaus(false);
if such then begin
assign(dat,dateinam);rewrite(dat);
outtextxy(130,156,'0 M”glichkeiten gefunden.');
end;
st:=erg[12];
erg[12]:=erg[11];
erg[11]:=st;
repeat
if interpret(st)=0 then begin
wvmogl:=wvmogl+1;
if such then begin
str(wvmogl,s);
bar(130,156,194,164);outtextxy(130,156,s);
for i:=1 to 12 do write(dat,zazto[erg[i]]+' ');
writeln(dat);
end
else begin
erga:=erg;
prozent(wv,wvmogl,wvmogl-1);
end;
end;
st:=erg[12];
erg[12]:=erg[11];
erg[11]:=st;
i:=interpret(sta);
if sta=0 then st:=10 else st:=i+sta;
if i=0 then begin
wvmogl:=wvmogl+1;
if such then begin
str(wvmogl,s);
bar(130,156,194,164);outtextxy(130,156,s);
for i:=1 to 12 do write(dat,zazto[erg[i]]+' ');
writeln(dat);
end
else if wvmogl<=wv then begin
erga:=erg;
prozent(wv,wvmogl,wvmogl-1);
end;
end;
if st>10 then st:=10;
repeat;
i:=1;sta:=st;
erg[st]:=erg[st]+1;
while i<st do begin
if erg[st]=erg[i] then begin erg[st]:=erg[st]+1;i:=0;end;
i:=i+1
end;
if erg[st]>12 then begin erg[st]:=1;st:=st-1;end;
until (st=sta) or (st=0);
sta:=st;
for st:=sta+1 to 12 do begin
erg[st]:=1;
i:=1;
while i<st do begin
if erg[st]=erg[i] then begin erg[st]:=erg[st]+1;i:=0;end;
i:=i+1
end;
end;
i:=1;verlschl:=true;
repeat
if erga[i]<>erg[i] then begin verlschl:=false;i:=12;end;
i:=i+1;
until i>12;
until (not such and (wv<=wvmogl)) or verlschl or(keypressed and(readkey=#27));
fehler:=wv>wvmogl+1;
if such then close(dat) else erg:=erga;
mausanaus(true);
end;
procedure persausw;
var verlschl:boolean;
xa,ya:byte;
xx:array[1..4]of word;
begin
xx[1]:=34;xx[2]:=333;xx[3]:=339;xx[4]:=637;
ya:=1;
if x>12 then x:=12;if x=0 then x:=1;
if y=0 then y:=1;if y>4 then y:=4;
if x<>12 then xa:=12 else xa:=11;
verlschl:=false;fehler:=false;
repeat
if x>12 then begin y:=y+1;x:=1;end;
if x=0 then begin y:=y-1;x:=12;end;
if y=0 then y:=4;
if y>4 then y:=1;
if(xa<>x)or(ya<>y)then begin
setfillstyle(1,f3);
mausanaus(false);
bar(xx[y],x*32+44,xx[y]+2,x*32+60);
if ya=1 then setfillstyle(1,8) else setfillstyle(0,0);
bar(xx[ya],xa*32+44,xx[ya]+2,xa*32+60);
mausanaus(true);
xa:=x;ya:=y;
end;
if keypressed then begin
case readkey of
#0:case readkey of
#71:begin y:=1;x:=1;end;
#72:x:=x-1;
#75:y:=y-1;
#77:y:=y+1;
#79:begin y:=4;x:=12;end;
#80:x:=x+1;
end;
#13:verlschl:=true;
#27:begin fehler:=true;verlschl:=true;end;
end;
end
else begin
mausles;
if maus.lt and mausber(40,76,633,451)then begin
x:=trunc((maus.y-44)/32);
y:=1;
if maus.x>183 then y:=2;
if maus.x>336 then y:=3;
if maus.x>488 then y:=4;
verlschl:=dbk;
end
else if maus.t then begin fehler:=true;verlschl:=true;end;
end;
until verlschl;
if ya=1 then setfillstyle(1,8)else setfillstyle(0,0);
mausanaus(false);
bar(xx[ya],xa*32+44,xx[ya]+2,xa*32+60);
mausanaus(true);
setfillstyle(0,0);
end;
procedure umkehrung;
var i,a:byte;
hv:shortint;
begin
erga:=erg;
for i:=2 to 12 do begin
hv:=erga[i-1]-erga[i];
if erg[i-1]+hv<1 then hv:=hv+12;
if erg[i-1]+hv>12 then hv:=hv-12;
erg[i]:=erg[i-1]+hv;
end;
end;
procedure zahl;
var i,a:byte;
begin
for i:=1 to wv do begin
for a:=1 to 12 do begin
erg[a]:=erg[a]-1;
if erg[a]=0 then erg[a]:=12;
end;
end;
end;
procedure perspek;
var i:byte;
begin
erg:=zeigp;
line(337,70,337,454);
for i:=1 to 12 do begin
darstell12t(40,i*32+44);
zahl(1);
end;
umkehrung;
for i:=1 to 12 do begin
darstell12t(345,i*32+44);
zahl(1);
end;
erg:=zeigp;
end;
begin
end.