-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSJ3UNIT.PAS
3242 lines (2305 loc) · 64.6 KB
/
SJ3UNIT.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
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
Unit SJ3UNIT;
{$I REGSTAT.PAS}
interface
procedure Init;
const NumPl = 75; { montako pelaajaa on ylip„„t„„n }
NumTeams = 15;
MaxOwnPl = 10; { montako omaa pelaajaa voi olla }
NumWCHills = 20; { montako m„ke„ World Cupissa }
MaxExtraHills = 1000; { montako extra m„ke„ voi olla. CHECK!!! }
MaxCustoms = 200; { montako custom hill filea .SJC voi olla }
HexCh : array[0..15] of char =
('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
WCpoints : array[1..30] of byte =
(100,80,60,50,45,40,36,32,29,26,24,22,20,18,16,
15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
{
Teampoints : array[1..6] of byte =
(10,6,4,3,2,1);
}
Teampoints : array[1..8] of integer =
(400,350,300,250,
200,150,100,50);
type Stat_type = record
CompPos : byte;
WCPos : byte;
CompPts : integer;
Round1Pos : byte;
RoundPts : array [0..2] of longint;
RoundLen : array [0..2] of integer;
Reason : array [0..2] of byte;
end;
HillStr = string[25];
TimeStr = string[22];
NameStr = string[30];
FileStr = string[8];
{
Key_type = record
JUMP1, JUMP2,
RIGHT1, RIGHT2,
LEFT1, LEFT2,
TELE1, TELE2,
TWO1, TWO2 : char;
end;
}
Key_type = record
A,B : char;
end;
Hill_type = record
Name : string[25];
Author : string[30];
Kr : integer;
FrIndex, BkIndex : string[3];
BkBright, BkMirror, VxFinal : byte;
Pk, PlSave : single;
Profile : longint;
HRName : NameStr;
HRLen : integer;
HRTime : TimeStr;
end;
Hillinfo_type = record
Name : HillStr;
Kr : integer;
HRName : NameStr;
HRLen : integer;
HRTime : TimeStr;
end;
(*
Hillrec = record
Name : NameStr;
Len : integer;
Time : TimeStr;
end;
*)
Hiscore = record
Name : NameStr;
Pos : byte;
Score : Longint;
Time : TimeStr;
end;
Date = record
Year,Month,Day,DayofWeek : Word;
end;
Time = record
Hour, Minute, Second, Sec100 : Word;
end;
var NumHills, Vcode : byte;
NumExtraHills : word;
{function getch(xx,yy:integer;bkcolor:byte):char;}
procedure getch(xx,yy:integer;bkcolor:byte;var tempch,tempch2:char);
function getstr(xx,yy,maxlength:integer;oldstr:string;bkcolor:byte):string;
function getstr2(xx,yy,maxchars:integer;oldstr:string;bkcolor:byte):string;
procedure lopputext(version:string;a1,a2:Time);
function MakeMenu(x,y,length,height,items,index:integer;bgcolor,phase,tab:byte):integer;
function LoadHill(var KeulaX:integer;nytmaki:integer;Acthill:hill_type):byte;
Function waitforkey3(xx,yy:integer;var ch:char):boolean;
procedure teamwarning;
procedure newunregtext;
{procedure mainmenutext(phase:byte;reg:boolean); }
procedure mainmenutext(phase:byte;version:string);
procedure unregendtext;
procedure newregtext(regname,regnumber:string);
procedure regendtext(regname,regnumber:string);
function makeletter(temp:integer):char;
procedure resultbox(phase:byte;result:integer);
function hillfile(nyt:integer):string;
{ procedure WriteExtraHillHR(index:integer);}
function fexist(filename:string):boolean;
procedure CheckExtraHills;
procedure LoadHillInfo;
procedure GetNow(var Now:Time);
function LoadInfo(nytmaki:integer;
var hill:hill_type):byte;
procedure choosewindplace(var place:byte);
function WindPlaceName(place:byte):string;
procedure SetupItem(index,screen,entries:byte;str1:string);
procedure HillMaker(phase:byte);
{ procedure HillEditor(phase:byte); }
procedure setgoals;
function loadgoal(num:integer):integer;
function hillkr(nytmaki:integer):integer;
function hillname(nytmaki:integer):HillStr;
function hillcode(nytmaki:integer):longint;
function HRname(nytmaki:integer):NameStr;
function HRLen(nytmaki:integer):integer;
function HRTime(nytmaki:integer):TimeStr;
procedure SetHRinfo(nytmaki:integer;name:NameStr;len:integer;time:TimeStr);
function replayinfo(var filename, author, name:string;nytmaki,hp:integer):byte;
procedure WriteExtras;
procedure ReadExtras;
function quitting(phase:byte):byte;
function dayandtime(D1:Date;T1:Time):string;
Function Luehaalarit(index,col:byte):byte;
function injured:shortint;
function keyname(chw:word):string;
function kword(ch1,ch2:char):word;
procedure DefaultKeys(var K:array of word);
procedure ConfigureKeys(var K:array of word);
function crypt(arvo:longint;jarj:integer):string;
function uncrypt(str0:string;jarj:integer):longint;
function valuestr(str0:string;arvo:integer):word;
function svaluestr(str0:string;arvo:integer):word;
function choosehill(mmaara:byte):byte;
procedure kothchallenge(x:integer;kothpack:byte);
function kothtitle(temp:integer):string;
function lengthpoint(kr:integer):integer;
function mightdelete(filestr:string):byte;
procedure DoCoachCorner(height,kulmalaskuri:integer;grade,ponn,style:byte);
{procedure DrawLumi(delx,dely,wind:integer;lmaara:word); }
procedure DrawLumi(delx,dely,wind:integer;lmaara:word;draw:boolean);
procedure makevcode(version:string;reg:boolean);
(*
function ReadKey : char { in lieu of Crt.ReadKey } ;
*)
(*
procedure Textcolor(col:byte);
procedure Textbackground(col:byte);
procedure GotoXY(x,y:integer);
procedure Window(x1,y1,x2,y2:integer);
procedure clrscr;
*)
implementation
uses crt, dos, sj3help, sj3graph, sj3lang, maki, lumi, sj3pcx, sdlport, SysUtils;
{var osote : array [0..4000] of byte; }
var HD : array[0..NumWCHills+MaxExtraHills] of ^Hillinfo_type;
(*
mnimet : array[0..NumWCHills+MaxExtraHills] of HillStr;
kri : array[0..NumWCHills+MaxExtraHills] of integer;
*)
(*
function ReadKey : char { in lieu of Crt.ReadKey } ;
const Buff : char = #0 ; var R : Tregisters ;
begin
if Buff<>#0 then begin ReadKey := Buff ; Buff := #0 end else
with R do begin AH := 0 ; Intr($16, R) ;
if AL=0 then Buff := char(AH) ;
ReadKey := char(AL) end ;
end {ReadKey} ;
*)
(*
function ReadKey : char ; assembler ; { ei extended }
asm
mov AH,00h;
int 16h
end {ReadKey};
*)
(*
function ReadKey : char ; assembler ; { toimii melkein }
asm
mov AH,08h;
int 21h
end {ReadKey};
*)
{
procedure Textcolor(col:byte); begin end;
procedure Textbackground(col:byte); begin end;
procedure GotoXY(x,y:integer); begin end;
procedure Window(x1,y1,x2,y2:integer); begin end;
procedure clrscr; begin end;
}
procedure makevcode(version:string;reg:boolean);
var pos : byte;
begin
pos:=2; { v3.11 !!! }
if (reg) then pos:=4;
if ((vcode and pos)=0) then vcode:=(vcode or pos);
end;
function lengthpoint(kr:integer):integer;
var return : integer;
begin
return:=10;
case kr of
0..24 : return:=48;
25..29 : return:=44;
30..34 : return:=40;
35..39 : return:=36;
40..49 : return:=32;
50..59 : return:=28;
60..69 : return:=24;
70..79 : return:=22;
80..99 : return:=20;
100..130: return:=18;
131..200: return:=12;
201..999: return:=10;
end;
(*
K-Point Distance Meter Value
20 to 24 m . . . . . . . . . . . . . . 4.8 pts./m
25 to 29 m . . . . . . . . . . . . . . 4.4 pts./m
30 to 34 m . . . . . . . . . . . . . . 4.0 pts./m
35 to 39 m . . . . . . . . . . . . . . 3.6 pts./m
40 to 49 m . . . . . . . . . . . . . . 3.2 pts./m
50 to 59 m . . . . . . . . . . . . . . 2.8 pts./m
60 to 69 m . . . . . . . . . . . . . . 2.4 pts./m
70 to 79 m . . . . . . . . . . . . . . 2.2 pts./m
80 to 99 m . . . . . . . . . . . . . . 2.0 pts./m
100 to 120 m . . . . . . . . . . . . . . 1.8 pts./m
145 to 185 m . . . . . . . . . . . . . . 1.2 pts./m
*)
lengthpoint:=return;
end;
{function givech(xx,yy:integer;bkcolor:byte):char;}
procedure givech(xx,yy:integer;bkcolor:byte;var tempch,tempch2:char);
var run : integer;
col : byte;
begin
run:=0;
repeat
inc(run); if (run>20) then run:=0;
col:=240;
if (run>10) then col:=bkcolor;
fillbox(xx,yy+6,xx+4,yy+6,col);
DrawScreen;
until (SDLPort.KeyPressed);
SDLPort.WaitForKeyPress(tempch,tempch2);
fillbox(xx,yy+6,xx+4,yy+6,bkcolor);
writefont(xx,yy,tempch);
{ givech:=ch; }
end;
{function getch(xx,yy:integer;bkcolor:byte):char;}
procedure getch(xx,yy:integer;bkcolor:byte;var tempch,tempch2:char);
begin
fillbox(xx-2,yy-2,xx+6,yy+8,bkcolor);
givech(xx,yy,bkcolor,tempch,tempch2);
DrawScreen;
{ getch:=ch; }
end;
function getstr(xx,yy,maxlength:integer;oldstr:string;bkcolor:byte):string;
var newstr : string;
out : boolean;
cx : integer;
{ tempch, tempch2 : char; }
begin
out:=false;
newstr:=oldstr;
repeat
cx:=fontlen(newstr);
fillbox(xx-2,yy-2,xx+maxlength+2,yy+7,bkcolor);
writefont(xx,yy,newstr);
DrawScreen;
givech(xx+cx,yy,bkcolor,ch,ch2);
if (ch2=#83) then delete(newstr,1,length(newstr));
case ch of
#8 : delete(newstr,length(newstr),1);
#13,#27 : out:=true;
{
#32..#254 : if (cx+7 < maxlength) then newstr:=newstr+tempch; }
{ '0'..'9','A'..'Z','','Ž','™',
'a'..'z','†','„','”','.',',','#','!','(',')','-', }
#32..#254 : if (cx+7 < maxlength) and (fontlen(ch)>0) then newstr:=newstr+ch;
end; { case }
until (out);
if (ch=#27) then newstr:=oldstr;
getstr:=newstr;
end;
function getstr2(xx,yy,maxchars:integer;oldstr:string;bkcolor:byte):string;
var newstr : string;
out : boolean;
cx : integer;
{ tempch, tempch2 : char; }
begin
out:=false;
newstr:=oldstr;
repeat
cx:=fontlen(newstr);
fillbox(xx-2,yy-2,xx+(maxchars*7)+2,yy+8,bkcolor);
writefont(xx,yy,newstr);
DrawScreen;
givech(xx+cx,yy,bkcolor,ch,ch2);
if (ch2=#83) then delete(newstr,1,length(newstr));
case ch of
#8 : delete(newstr,length(newstr),1);
#13,#27 : out:=true;
{
#32..#254 : if (cx+7 < maxlength) then newstr:=newstr+tempch; }
{ '0'..'9','A'..'Z','','Ž','™',
'a'..'z','†','„','”','.',',','#','!','(',')','-', }
#32..#254 : if (length(newstr) < maxchars) and (fontlen(ch)>0) then newstr:=newstr+ch;
end; { case }
until (out);
if (ch=#27) then newstr:='ÿ';
getstr2:=newstr;
end;
Procedure GetNow(var Now:Time);
begin
gettime(Now.Hour,Now.Minute,Now.Second,Now.Sec100);
end;
function kothtitle(temp:integer):string;
var str1 : string;
begin
case temp of
1..6 : str1:=txt(temp)+'. '+lstr(130+temp);
0,7 : str1:='0. '+lstr(137);
end;
kothtitle:=str1;
end;
function loadgoal(num:integer):integer;
var temp, value:integer;
f2 : text;
begin
assign(f2,'GOALS.SKI');
{$I-}
reset(f2);
{$I+}
value:=0;
if (IOResult=0) and (num>0) and (num<=numwchills) then
begin
for temp:=1 to num do
readln(f2,value);
close(f2);
end;
loadgoal:=value;
end;
procedure setgoals;
var goals : array[0..numwchills] of integer;
temp, y : integer;
oldindex, index : integer;
leave : boolean;
{ tempch1, tempch2 : char; }
procedure loadgoals;
var f2 : text;
temp2 : integer;
begin
assign(f2,'GOALS.SKI');
{$I-}
reset(f2);
{$I+}
if (IOResult=0) then
begin
for temp2:=1 to NumWCHills do
readln(f2,goals[temp2]);
close(f2);
end;
end;
procedure writegoals;
var f2 : text;
temp2 : integer;
begin
assign(f2,'GOALS.SKI');
{$I-}
rewrite(f2);
{$I+}
if (IOResult=0) then
begin
for temp2:=1 to NumWCHills do
writeln(f2,goals[temp2]);
close(f2);
end;
end;
procedure drawgoal(temp2,phase:integer);
begin
if (phase=0) then fontcolor(240) else fontcolor(246);
y:=(temp2*8)+24;
fillbox(168,y-2,202,y+6,243);
fillarea(168,y-2,202,y+6,63);
if (temp2>20) then ewritefont(200,y,lstr(154))
else ewritefont(200,y,txtp(goals[temp2]));
end;
begin
loadgoals;
Newscreen(1,0);
fontcolor(240);
writefont(30,6,lstr(200));
fontcolor(241);
writefont(40,13,lstr(243));
fontcolor(246);
writefont(24,23,lstr(106));
ewritefont(200,23,lstr(242));
ewritefont(250,23,'K');
ewritefont(300,23,'HR');
index:=1;
leave:=false;
for temp:=1 to NumWcHills do
begin
y:=(temp*8)+24;
fontcolor(246);
ewritefont(18,y,txt(temp)+'.');
fontcolor(240);
writefont(24,y,nsh(hillname(temp),140));
{ ewritefont(200,y,txtp(goals[temp])); }
drawgoal(temp,0);
fontcolor(247);
ewritefont(250,y,txtp(hillkr(temp)*10));
ewritefont(300,y,txtp(HRLen(temp)));
end;
inc(temp); drawgoal(temp,0); { exit }
repeat
y:=(index*8)+24;
drawgoal(index,1);
box(168,y-2,202,y+6,240);
drawscreen;
clearchs;
SDLPort.WaitForKeyPress(ch,ch2);
oldindex:=index;
if ((ch2=#75) or (ch='-')) and (goals[index]>4) then dec(goals[index],5);
if ((ch2=#77) or (ch='+')) and (goals[index]<2500) then inc(goals[index],5);
if (ch2=#72) and (index>1) then dec(index);
if (ch2=#80) and (index<21) then inc(index);
if ((ch=#13) and (index=21)) or (ch2=#68) then leave:=true;
if (ch=#27) or (ch2=#79) then index:=21;
if (ch2=#71) then index:=1;
drawgoal(oldindex,0);
until (leave);
writegoals;
end;
procedure DrawLumi(delx,dely,wind:integer;lmaara:word;draw:boolean);
begin
{ temp:=(tuuli div abs(tuuli))*(random(abs(tuuli)) div 10);
Lumi.Update(Video,128,(delx*2)+temp,dely*2); }
{ Lmaara:=240;
tuuli:=-40; }
if (LMaara>0) then Lumi.Update(Video,delx*2,dely*2,wind*8,draw);
{ writefont(1,192,txt(wind)); }
{ if (LMaara>0) then Lumi.Update(Video,LMaara,delx*2,dely*2,tuuli); }
end;
procedure kothchallenge(x:integer;kothpack:byte);
var temp : integer;
y : integer;
begin
fontcolor(246);
writefont(x,110,lstr(130));
y:=120;
if (kothpack=0) then kothpack:=7;
for temp:=1 to 7 do
begin
fontcolor(241);
if (temp=kothpack) or (kothpack=255) then fontcolor(240);
writefont(x,y,kothtitle(temp));
inc(y,8); if (temp=6) then inc(y,8); { ylim„„r„iset }
end;
end;
function LoadHill(var KeulaX:integer;nytmaki:integer;Acthill:hill_type):byte;
var temp : integer;
l : longint;
str1 : string;
res : byte;
begin
res:=0;
LataaPCX('LOAD.PCX',320*200,0,0);
SiirraStandardiPaletti;
AsetaPaletti;
WriteVideo;
{ FillBox(0,0,319,199,242); }
{ NewScreen(5,0); }
{ FontColor(240);
MuutaLogo(2);
WriteFont(60,90,'LOADING HILL...');
DrawAnim(148,90,62);
WriteFont(185,99,'...PLEASE WAIT');
AsetaPaletti; }
str1:=txt(Acthill.kr);
Fontcolor(246); { 205 }
{ Writefont(160-fontlen(str1) div 2,97,str1); }
EWritefont(311,107,str1);
Fontcolor(240);
EWritefont(311-Fontlen(str1),107,Acthill.name+' K');
DrawScreen;
LataaPCX('FRONT'+Acthill.frindex+'.PCX',1024*512,0,0);
TallennaAlkuosa(1);
LaskeLinjat(KeulaX,acthill.kr,acthill.pk);
l:=0;
for temp:=0 to 1023 do
inc(l,longint(profiili(temp)*(temp mod 13+profiili(temp) mod 11)) mod 13313);
dec(l,1500000);
LataaPCX('BACK'+acthill.bkindex+'.PCX',1024*400,Maki.Sivuja,acthill.bkmirror);
TakaisinAlkuosa(1);
if (l<>acthill.profile) then { profiilichekkaus }
begin
alertbox;
str1:='RUN THE HILL MAKER AGAIN.';
if (nytmaki<=NumWCHills) then
begin
res:=1;
str1:='EXITING CUP.';
end;
writefont(80,90,'THE PROFILE OF HILL #'+acthill.frindex);
writefont(80,102,'HAS BEEN CHANGED! NOT GOOD.');
writefont(80,114,str1);
writefont(80,130,'PRESS A KEY...');
drawscreen;
waitforkey;
end;
SavytaPaletti(1,acthill.bkbright);
Loadhill:=res;
end;
function MakeMenu(x,y,length,height,items,index:integer;bgcolor,phase,tab:byte):integer;
var{ tempch1,tempch2 : char; }
{ index : integer; }
xx,yy : integer;
out,fill,putkeen : boolean;
boxcol : byte;
del : boolean;
oldindex : integer;
thing : integer;
begin { phase: 0 - DEL ei k„y, 1 - DEL k„y, 2 - 2 columns! DEL k„y }
{ 3 - kaikki putkeen, 4 - ei fillarea, 5 - old players }
{ 6 - new profiles, 7 - kaikki putkeen & ei fill }
out:=false;
del:=false; { delete n„pp„in ei k„yt”ss„ }
thing:=63;
if (phase=5) then begin thing:=64; phase:=1; end;
case phase of
1,2,6 : del:=true;
end;
fill:=true;
case phase of
4,7 : fill:=false;
end;
putkeen:=false;
case phase of
3,7 : putkeen:=true;
end;
{ if (phase=2) then cols:=2; }
{ index:=1; }
index:=abs(index);
xx:=x-6;
yy:=y-3+((index-1)*height);
(*
if (index>tab) and (cols=2) then
begin
xx:=x+160-6;
yy:=y-3+((index-1-tab)*height);
end;
*)
boxcol:=240;
repeat
box(xx,yy,xx+length,yy+height,bgcolor);
if (fill) then fillarea(xx,yy,xx+length,yy+height,thing);
clearchs; oldindex:=index;
if (SDLPort.KeyPressed) then SDLPort.WaitForKeyPress(ch,ch2);
case (ch2) of
#72,#75 :{ if (cols=2) and (tempch2=#75) and (index>tab) then dec(index,tab)
else }
begin
if (index>1) then dec(index)
else index:=items+2;
if (index=items+1) then dec(index); { skip v„li }
{ boxcol:=32; }
end;
#77,#80 :{ if (cols=2) and (tempch2=#77) then inc(index,tab)
else }
begin
if (index<items+1) then inc(index)
else index:=1;
if (index=items+1) then inc(index); { skip v„li }
{ boxcol:=32; }
end;
#59..#68 : begin
index:=ord(ch2)-58;
out:=true;
end;
end; { case }
case (ch) of
'0'..'9' : index:=ord(ch)-48;
'A'..'L' : if (phase<>6) then index:=ord(ch)-55; { me halutaan ett„ E on edit }
'a'..'l' : index:=ord(ch)-87;
end;
if (index<=0) or (index>items) then
begin
index:=items+2;
if (putkeen) then index:=items+1;
end;
if (ch2=#71) then index:=1;
if (ch=#27) or (ch2=#79) then
begin
index:=items+2;
if (putkeen) then index:=items+1;
end;
if (ch2=#68) then { F10 }
begin
out:=true;
index:=items+2;
if (putkeen) then index:=items+1;
if (phase=6) then index:=254;
end;
if (ch=#9) and (tab>0) then
begin { tab }
out:=true;
if (tab<254) then index:=tab;
if (tab=255) then index:=items+2;
end;
if (ch=#13) or (ch=' ') then out:=true;
xx:=x-6;
yy:=y-3+((index-1)*height);
if (phase=6) and ((ch=#13) or (upcase(ch)='E') or (ch=#9)) then
begin
index:=tab;
out:=true;
end;
(*
if (index>tab) and (cols=2) then
begin
xx:=x+160-6;
yy:=y-3+((index-1-tab)*height);
end;
*)
{ inc(boxcol); if (boxcol>47) then boxcol:=16; }
box(xx,yy,xx+length,yy+height,boxcol);
DrawScreen;
if (ch2=#83) and (del) then begin out:=true; index:=-index; end; { delete! }
if (phase=6) and (index<>oldindex) then out:=true;
until (out);
box(xx,yy,xx+length,yy+height,bgcolor);
if (fill) then fillarea(xx,yy,xx+length,yy+height,thing);
if (phase<>6) then
begin
DrawScreen;
if (index>items) then index:=0; { exit }
end;
clearchs;
MakeMenu:=index;
end;
procedure DoCoachCorner(height,kulmalaskuri:integer;grade,ponn,style:byte);
var wstr : string;
cstr : array[0..5] of string;
temp, index, count,x,y : integer;
begin
for temp:=0 to 5 do cstr[temp]:='';
index:=360+style*40;
case kulmalaskuri of
0..49 : cstr[0]:=lstr(index+2);
50..61 : cstr[0]:=lstr(index+3);
62..200 : cstr[0]:=lstr(index+4);
end;
if (grade<10) then
begin
case grade of
1 : cstr[1]:=lstr(index+5);
2 : cstr[1]:=lstr(index+6);
3 : cstr[1]:=lstr(index+7);
end;
end else
begin
case grade div 10 of
1..5 : cstr[1]:=lstr(index+10);
6..8 : cstr[1]:=lstr(index+11);
9 : cstr[1]:=lstr(index+12);
10 : cstr[1]:=lstr(index+13);
11 : cstr[1]:=lstr(index+14);
12..20 : cstr[1]:=lstr(index+15);
end;
end;
case ponn of
0..5 : cstr[2]:=lstr(index+18);
6..9 : cstr[2]:=lstr(index+19);
10..12 : cstr[2]:=lstr(index+20);
13..15 : cstr[2]:=lstr(index+21);
16 : cstr[2]:=lstr(index+22);
17..19 : cstr[2]:=lstr(index+23);
20..23 : cstr[2]:=lstr(index+24);
24..50 : cstr[2]:=lstr(index+25);
end;
case height of
0..49 : cstr[3]:=lstr(index+28);
50..55 : cstr[3]:=lstr(index+29);
56..60 : cstr[3]:=lstr(index+30);
61..64 : cstr[3]:=lstr(index+31);
65..70 : cstr[3]:=lstr(index+32);
71..90 : cstr[3]:=lstr(index+33);
91..200 : cstr[3]:=lstr(index+34);
end;
if (grade<10) then cstr[0]:=cstr[1]; { jos kupat n„es }
if (grade=1) then cstr[3]:=lstr(index+35);
cstr[1]:=cstr[random(2)];
cstr[2]:=cstr[random(2)+2];
cstr[1]:=cstr[1]+'*'+cstr[2];
FontColor(252);
DrawAnim(3,150,65);
writefont(12,150,lstr(400));
index:=1;
x:=12; y:=160;
writefont(x,y,'"');