-
Notifications
You must be signed in to change notification settings - Fork 5
/
BASICINT.PAS
3302 lines (3246 loc) · 92.9 KB
/
BASICINT.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 BasicInterpretor;
INTERFACE
{$I DEF.INC}
{$N+}
Procedure RunBasicInterpretor;
IMPLEMENTATION
Uses {$IFDEF Adele}Adele,{$ELSE}Chantal,Goldnaxe,{$ENDIF}
Systex,Isatex,Systems,Video,Mouse,Pritex,Dialex,Dials,DialPlus,
Editor,EdtLoad,EdtSearc,EdtDone,InfoMemo,Math,Numerix,H,Memories;
Const
bpNew=$F001;
bpOpen=$F002;
bpSave=$F003;
bpSaveAs=$F004;
bpRun=$F005;
bpOutput=$F006;
bpPreviousWn=$F007;
bpNextWn=$F008;
bpAbout=$F009;
bpExit=$F00A;
ExitProgramNow=-666;
StopProgram=-777;
Type
NmType=Record
Format:Byte;
Case Byte of
0:(Int,IntHi:Integer);
1:(Word:Word);
2:(Long:LongInt);
3:(Single:Single);
4:(Double:Double);
End;
Var
K,IT,JT,SegBas:Word;
Output,MS:ImgRec;
{$IFDEF HeapVram}
OldHeapVram:Bool;
{$ENDIF}
OldMode:Byte;
Boucle:Array[0..63]of Record
Model:(BNo,BFor,BWhile,BDo);
X,Y,X2,X3:Word;
Data:Array[0..6]of Byte;
End;
Gosub:Array[0..63]of Record
X,Y:Word;
End;
BouclePos,GosubPos:Byte;
Data:Array[0..47999]of Byte;
CurData:Word;
RunXit:SmallInt;
PC:PChr;
InKeyB:SmallInt;
Regs:Registers;
{$I \Source\Chantal\Library\Intr.Inc}
Procedure SetPaletteRGB(A,R,G,B:Int);Var X:RGB;Begin
X.R:=R;X.G:=G;X.B:=B;
SetPalRGB(X,A,1);
End;
Procedure PutMnu;Begin
WEPutLastBar('^F2^ Sauvegarder ^F3^ Ouvre');
End;
Procedure About;
Var
W,W2:Window;
I:Byte;
K:Word;
Begin
WEInitO(W,39,12);
WEPushWn(W);
WEPutWnKrDials(W,'A propos!');
WELn(W);
WEPutOTxt(W,'Basic PRO');
WELn(W);
WEPutOTxt(W,'Version 1.0');
WELn(W);
WEPutOTxt(W,'Tous droits r‚serv‚s (c) par');
WELn(W);
WEPutOTxt(W,'Les Chevaliers de Malte');
Repeat
K:=WEGetkHorDn(W,'Correcte|D‚tails');
Case(K)of
0,kbAbort:Break;
1:Begin
WEInitO(W2,40,20);
WEPushWn(W2);
WEPutWnKrDials(W2,'A propos D‚taill‚');
WELn(W2);
WEPutTxtLn(W2,'Fabriqu‚ au: Qu‚bec Libre!!!');
WEPutTxtLn(W2,'crit en: Borland Pascal 7');
WEPutTxtLn(W2,'Lignes de code: 30 000 Pascal');
WEPutTxtLn(W2,' 10 000 Assembleur');
WEPutTxtLn(W2,'Taille du Source: 3 MegaOctets');
WEPutTxtLn(W2,'BibliothŠques: Malte Genesis IV');
WEPutTxtLn(W2,' Alias Chantal');
WEPutTxtLn(W2,' & Extension Malte Genesis V');
WEPutTxtLn(W2,' Alias AdŠle');
WEPutTxtLn(W2,'Date de frabric.: Janvier 1998');
WEPutTxtLn(W2,'M‚thode de fabr.: La patience voyont!');
WELn(W2);
WEPutTxtLn(W2,'Programmeur/Concepteur/Analyste:');
WELn(W2);
WEPutTxtLn(W2,' Sylvain Maltais');
While WEOk(W2)do;
End;
End;
Until No;
WEDone(W);
End;
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Proc‚dure LockOutput Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette proc‚dure permet de voir l'‚cran de sortie de l'application. C'est
l'‚cran DOS d'o— le programme arrive... (Output)!
}
Procedure LookOutput;
Var
MS:ImgRec;
I:Word;
{$IFDEF HeapVram}
OldHeapVram:Boolean;
{$ENDIF}
Procedure PutErr;Begin
If GetSysErr>0Then ErrMsgOk(WordToStr(I)+':'+GetErrMsg(GetSysErr))
End;
Begin
DialTimer:=False;
{$IFDEF HeapVram}
OldHeapVram:=HeapVram;
{$ENDIF}
__HideMousePtr;
PushScr(MS);
I:=1;
PutErr;
{$IFDEF HeapVram}
HeapVram:=False;
{$ENDIF}
PopScr(Output);I:=2;PutErr;
SimpleCur;
__ShowMousePtr;
Repeat{While ReadKey=7do CarteBios;}
Case(ReadKey)of
7:CarteBios;
{ kbCtrlIns:ClipBoardOutput;}
Else Break;
End;
Until No;
__HideMousePtr;
PushScr(Output);I:=3;PutErr;
{$IFDEF HeapVram}HeapVram:=OldHeapVram;{$ENDIF}
PopScr(MS);I:=4;PutErr;
__ShowMousePtr;
DialTimer:=Ya;
End;
Procedure MakeMnu;Begin
PMInit;
PMSetWinBar(0,1,MaxXTxts);
PMAddMnu('^F^ichier');
PMAddItemKey('^N^ouveau',kbNoKey,bpNew,'Cr‚e un nouveau programme BASIC');
PMAddItemKey('^O^uvre',kbF3,bpOpen,'Ouvre un programme BASIC d‚j… existant ou en cr‚e un s''il n''existe pas encore');
PMAddItemKey('^S^auve',kbF2,bpSave,'Sauvegarde le programme sous son nom courant');
PMAddItemKey('Sauve sous',kbNoKey,bpSaveAs,'Sauvegarde le programme sous un nom particulier');
PMAddItemKey('^Q^uitter',kbAltX,bpExit,'Quitter le programme');
PMAddMnu('^C^ommande');
PMAddItemKey('E^x^‚cution',kbCtrlF9,bpRun,'Ex‚cute le programme BASIC courant');
PMAddItemKey('^S^ortie',kbAltF5,bpOutput,'Voir la sortie ‚cran...');
PMAddMnu('F^e^nˆtre');
PMAddItemKey('^S^uivante',kbF6,bpNextWn,'Passe … la fenˆtre suivante');
PMAddItemKey('^P^r‚c‚dente',kbShiftF6,bpPreviousWn,'Passe … la fenˆtre pr‚c‚dente');
PMAddMnu('^A^ide');
PMAddItemKey('^A^ propos',kbNoKey,bpAbout,'Indique les informations concernant ce programme...');
PMPutMnuBar;
End;
{$I Library\Joystick\Button.Inc}
{$I Library\OctWord2Str.Inc}
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Fonction PXtrkWord Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette fonction permet d'extraire une mot litt‚raire d'une chaŒne de
caractŠres de style ASCIIZ (langage de programmation C).
}
Procedure PXtrkWord(Var W:String);Near;Assembler;ASM
LES DI,PC
ADD DI,IT
MOV CL,ES:[DI]
AND CL,0DFh
CMP CL,'A'
JB @Empty
CMP CL,'Z'
JA @Empty
INC Word Ptr IT
MOV AH,ES:[DI]
MOV AL,1
LES DI,W
STOSW
@1:LES DI,PC
ADD DI,IT
MOV CL,ES:[DI]
AND CL,0DFh
CMP CL,'A'
JB @Brk
CMP CL,'Z'
JA @Brk
LES BX,W
CMP Byte Ptr ES:[BX],255
JE @Brk
INC Byte Ptr ES:[BX]
ADD BL,ES:[BX]
ADC BH,0
MOV ES:[BX],CL
INC IT
JMP @1
@Empty:
XOR AL,AL
LES DI,W
STOSB
@Brk:
END;
Const EndData=0;
DataInteger=1;
DataLong=2;
DataSingle=3;
DataDouble=4;
DataString=5;
DataPChar=6;
DataTLong=7;
DataSize:Array[EndData..DataTLong]of Word=(
0,SizeOf(Integer),SizeOf(Long),SizeOf(Single),
SizeOf(Double),SizeOf(String),0,SizeOf(Pointer)+SizeOf(Word)
);
Procedure PushVarInt(X:Integer;Var N:String);Near;Label 1;Var Jmp,J,L,Ofs:Word;Begin
{Recherche d'une variable existante}
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
MOV Ofs,BX
END;
Goto 1;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
{Affectation}
If CurData+Length(N)+6>SizeOf(Data)Then Exit;
Data[CurData]:=DataInteger;Inc(CurData);Jmp:=CurData+2+SizeOf(Integer)+Length(N)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
Ofs:=CurData;Inc(CurData,SizeOf(Integer));
MoveLeft(N,Data[CurData],Length(N)+1);
Inc(CurData,Length(N)+1);
1:
ASM
{ Copie les donn‚es }
MOV AX,X
MOV BX,Ofs
MOV Word Ptr Data[BX],AX
END;
End;
Procedure PushVarLong(X:Long;Var N:String);Near;Label 1;Var Jmp,J,L,Ofs:Word;Begin
{Recherche d'une variable existante}
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
MOV Ofs,BX
END;
Goto 1;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
{Affectation}
If CurData+Length(N)+8>SizeOf(Data)Then Exit;
Data[CurData]:=DataLong;Inc(CurData);Jmp:=CurData+2+SizeOf(Long)+Length(N)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
Ofs:=CurData;Inc(CurData,SizeOf(LongInt));
MoveLeft(N,Data[CurData],Length(N)+1);
Inc(CurData,Length(N)+1);
1:
ASM
{ Copie les donn‚es }
LES AX,X
MOV BX,Ofs
MOV Word Ptr Data[BX],AX
MOV Word Ptr Data[BX+2],ES
END;
End;
Procedure PushVarSingle(X:Single;Var N:String);Near;Label 1;Var Jmp,J,L,Ofs:Word;Begin
{Recherche d'une variable existante}
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
MOV Ofs,BX
END;
Goto 1;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
{Affectation}
If CurData+Length(N)+8>SizeOf(Data)Then Exit;
Data[CurData]:=DataSingle;Inc(CurData);Jmp:=CurData+2+SizeOf(Single)+Length(N)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
Ofs:=CurData;Inc(CurData,SizeOf(Single));
MoveLeft(N,Data[CurData],Length(N)+1);
Inc(CurData,Length(N)+1);
1:
ASM
{ Copie les donn‚es }
LES AX,X
MOV BX,Ofs
MOV Word Ptr Data[BX],AX
MOV Word Ptr Data[BX+2],ES
END;
End;
Procedure PushVarDouble(X:Double;Var N:String);Near;Label 1;Var Jmp,J,L,Ofs:Word;Begin
{Recherche d'une variable existante}
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
MOV Ofs,BX
END;
Goto 1;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
{Affectation}
If CurData+Length(N)+12>SizeOf(Data)Then Exit;
Data[CurData]:=DataDouble;Inc(CurData);Jmp:=CurData+2+SizeOf(Double)+Length(N)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
Ofs:=CurData;Inc(CurData,SizeOf(Double));
MoveLeft(N,Data[CurData],Length(N)+1);
Inc(CurData,Length(N)+1);
1:
ASM
{ Copie les donn‚es }
LES AX,DWord Ptr X
MOV BX,Ofs
MOV Word Ptr Data[BX],AX
MOV Word Ptr Data[BX+2],ES
LES AX,DWord Ptr X[4]
MOV Word Ptr Data[BX+4],AX
MOV Word Ptr Data[BX+6],ES
END;
End;
Procedure PushVarString(Var X,N:String);Near;Label 1;Var Jmp,J,L,Ofs:Word;Begin
{Recherche d'une variable existante}
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
MOV Ofs,BX
END;
Goto 1;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
{Affectation}
If CurData+Length(N)+4+SizeOf(String)>SizeOf(Data)Then Exit;
Data[CurData]:=DataString;Inc(CurData);Jmp:=CurData+2+SizeOf(String)+Length(N)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
Ofs:=CurData;Inc(CurData,SizeOf(String));
MoveLeft(N,Data[CurData],Length(N)+1);
Inc(CurData,Length(N)+1);
1:
MoveLeft(X,Data[Ofs],SizeOf(String));
End;
Function PushVarStr2PChr(Var X:String):PChar;Near;Var Jmp:Word;P:PChr;Begin
If CurData+Length(X)+4>SizeOf(Data)Then Exit;
Data[CurData]:=DataPChar;Inc(CurData);Jmp:=CurData+2+Length(X)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
P:=@Data[CurData];
StrPCopy(P,X);Inc(CurData,Length(X)+1);
PushVarStr2PChr:=PChar(P);
End;
Function ReadVarInt(Var N:String):Integer;Near;Var L,J:Wd;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
MOV AX,Word Ptr Data[BX]
MOV @Result,AX
END;
Exit;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
ReadVarInt:=0;
End;
Function ReadVarLong(Var N:String):Long;Near;Var L,J:Wd;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
LES AX,DWord Ptr Data[BX]
MOV Word Ptr @Result,AX
MOV Word Ptr @Result[2],ES
END;
Exit;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
ReadVarLong:=0;
End;
Function ReadVarSingle(Var N:String):Single;Near;Var L,J:Wd;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
LES AX,DWord Ptr Data[BX]
MOV Word Ptr @Result,AX
MOV Word Ptr @Result[2],ES
END;
Exit;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
ReadVarSingle:=0.0;
End;
Function ReadVarDouble(Var N:String):Double;Near;Var L,J:Wd;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
MOV BX,J
ADD BX,3
LES AX,DWord Ptr Data[BX]
MOV Word Ptr @Result,AX
MOV Word Ptr @Result[2],ES
LES AX,DWord Ptr Data[BX+4]
MOV Word Ptr @Result[4],AX
MOV Word Ptr @Result[6],ES
END;
Exit;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
ReadVarDouble:=0.0;
End;
Function ReadVarString(Var N:String):String;Near;Var L,J:Wd;P:Pointer;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin
ASM
LES DI,@Result
MOV Word Ptr P,DI
MOV Word Ptr P[2],ES
END;
MoveLeft(Data[J+3],P^,SizeOf(String));
Exit;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
ReadVarString:='';
End;
Function PushVarTLong(Var N:String;T:Wd):Bool;Near;Var Jmp,J,L,Ofs:Wd;P:Pointer;Begin
{Recherche d'une variable existante}
J:=0;PushVarTLong:=No;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin;RunXit:=VarDupl;Exit;End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
{Affectation}
If CurData+Length(N)+8>SizeOf(Data)Then Begin;RunXit:=OutOfMemory;Exit;End;
P:=MemNew(T shl 2);
If(P=NIL)Then Begin;RunXit:=OutOfMemory;Exit;End;
Data[CurData]:=DataTLong;Inc(CurData);Jmp:=CurData+2+(SizeOf(Pointer)+2)+Length(N)+1;
ASM
{Fixe le Jump}
MOV AX,Jmp
MOV BX,CurData
MOV Word Ptr Data[BX],AX
ADD CurData,TYPE Integer
END;
Ofs:=CurData;Inc(CurData,SizeOf(Pointer)+2);
MoveLeft(N,Data[CurData],Length(N)+1);
Inc(CurData,Length(N)+1);
ASM
{ Copie les donn‚es }
LES AX,P
MOV BX,Ofs
MOV Word Ptr Data[BX],AX
MOV Word Ptr Data[BX+2],ES
MOV AX,T
MOV Word Ptr Data[BX+4],AX
END;
PushVarTLong:=Ya;
End;
Function AddrTLong(Var N:String;Var Size:Wd):Pointer;Near;Var L,J:Wd;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If(Data[J]=DataTLong)and(Compare(Data[L+J],N,Length(N)+1))Then Begin
ASM
MOV BX,J
ADD BX,3
LES AX,DWord Ptr Data[BX]
MOV Word Ptr @Result,AX
MOV Word Ptr @Result[2],ES
MOV AX,Word Ptr Data[BX+4]
LES DI,Size
STOSW
END;
Exit;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
AddrTLong:=NIL;
End;
Procedure NewMem;Var T,Jmp,J,Ofs:Wd;P:Pointer;Begin
{Recherche d'une variable existante}
J:=0;
While Data[J]<>0do Begin
Case Data[J]of
DataTLong:Begin
Ofs:=J+3;
ASM
{Copie les donn‚es}
MOV BX,Ofs
LES AX,DWord Ptr Data[BX]
MOV Word Ptr P,AX
MOV Word Ptr P[2],ES
MOV AX,Word Ptr Data[BX+4]
MOV T,AX
END;
FreeMem(P,T shl 2);
End;
End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
End;
Function OfsVar(Var N:String):Word;Near;Var L,J:Wd;P:Pointer;Begin
J:=0;
While Data[J]<>0do Begin
L:=DataSize[Data[J]]+3;
If Compare(Data[L+J],N,Length(N)+1)Then Begin;OfsVar:=J+3;Exit;End;
ASM
MOV BX,J
INC BX
MOV AX,Word Ptr Data[BX]
MOV J,AX
END;
End;
OfsVar:=$FFFF;
End;
Procedure SkipSpc;Near;Assembler;ASM {While PC^[IT]in[#9,' ']do Inc(IT);}
LES DI,PC
MOV BX,IT
DEC BX
@1:
INC BX
CMP Byte Ptr ES:[DI+BX],9
JE @1
CMP Byte Ptr ES:[DI+BX],' '
JE @1
MOV IT,BX
END;
Function _Str2S(Var S:String):Boolean;Near;Forward;
Function Nm(Var Xt:NmType):Bool;Near;Label _A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,
_O,_P,_Q,_R,_S,_T,_U,_V,_W,_X,_Y,_Z,1,VarCheck;
Var S,S2:String;A,B,C,R:NmType;Z:Long;PC2:Pointer Absolute Z;Ok:Bool;Chr:Char;Begin
Nm:=No;Xt.Format:=DataInteger;Xt.Int:=0;Chr:=#0;RunXit:=0;
If PC^[IT]='-'Then Begin;Chr:='-';Inc(IT)End;
Repeat
SkipSpc;
S:='';
While PC^[IT]in['0'..'9']do Begin;IncStr(S,PC^[IT]);Inc(IT)End;
If S=''Then Case PC^[IT]of
'(':Begin
Inc(IT);
If Not Nm(R)Then Exit;
SkipSpc;
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT)
End;
'&':Begin
Inc(IT);
Case Char(Byte(PC^[IT])and$DF)of
'B':Begin
Inc(IT);S:='';
While PC^[IT]in['0'..'9','A'..'F','a'..'f']do Begin;IncStr(S,PC^[IT]);Inc(IT)End;
R.Format:=DataInteger;R.Int:=BinStr2Nm(S);
End;
'H':Begin
Inc(IT);S:='';
While PC^[IT]in['0'..'9','A'..'F','a'..'f']do Begin;IncStr(S,PC^[IT]);Inc(IT)End;
R.Format:=DataInteger;
R.Int:=HexStrToInt(S);
End;
'O':Begin
Inc(IT);S:='';
While PC^[IT]in['0'..'7']do Begin;IncStr(S,PC^[IT]);Inc(IT)End;
R.Format:=DataInteger;R.Int:=OctStr2Nm(S)
End;
End;
End;
Else Begin
PXtrkWord(S);
If S=''Then Break;
ASM
XOR AX,AX
SUB AX,BP
MOV DI,Offset S
SUB DI,AX
INC DI
MOV BL,SS:[DI]
AND BX,001Fh
SHL BX,1
JMP Word Ptr @Label[BX]
@Label:
DW 0
DW Offset _A
DW Offset _B
DW Offset _C
DW Offset _D
DW Offset _E
DW Offset _F
DW Offset _G
DW Offset _H
DW Offset _I
DW Offset _J
DW Offset _K
DW Offset _L
DW Offset _M
DW Offset _N
DW Offset _O
DW Offset _P
DW Offset _Q
DW Offset _R
DW Offset _S
DW Offset _T
DW Offset _U
DW Offset _V
DW Offset _W
DW Offset _X
DW Offset _Y
DW Offset _Z
END;
_A: If S='ABS'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not Nm(A)Then Exit;
R.Int:=Abs(A.Int);
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);
Goto 1;
End;
If S='ALTPRESS'Then Begin;R.Format:=DataInteger;R.Int:=Byte(AltPress);Goto 1;End;
If S='ASC'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not _Str2S(S)Then Exit;
R.Format:=DataInteger;R.Int:=Byte(StrI(1,S));
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;
End;
Goto VarCheck;
_B: If S='BUS'Then Begin;R.Format:=DataInteger;R.Int:=Bus;Goto 1;End;
If S='BUTTON'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not Nm(A)Then Exit;
R.Format:=DataInteger;R.Int:=Byte(Button(A.Int));
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;
End;
Goto VarCheck;
_C: If S='CAPSLOCK'Then Begin;R.Format:=DataInteger;R.Int:=Byte(GetCapsLck);Goto 1;End;
If S='CMOS'Then Begin;R.Format:=DataInteger;R.Int:=CtrlCmos;Goto 1;End;
If S='CMOSEXIST'Then Begin;R.Format:=DataInteger;R.Int:=Byte(CmosExist);Goto 1;End;
If S='CMOSPORT'Then Begin;R.Format:=DataInteger;R.Int:=CmosPort;Goto 1;End;
If S='CODEPAGE'Then Begin;R.Format:=DataInteger;R.int:=CodePage;Goto 1;End;
If S='COLOR'Then Begin
R.Format:=DataInteger;
If(IsKr)Then R.Int:=Byte(GetNmColors)Else R.Int:=0;
Goto 1;
End;
If S='COMPUTERNAME'Then Begin;R.Format:=DataInteger;R.Int:=ComputerName;Goto 1;End;
If S='COUNTRY'Then Begin;R.Format:=DataInteger;R.Int:=CountryCode;Goto 1;End;
If S='CURRDISK'Then Begin;R.Format:=DataInteger;R.Int:=GetDsk;Goto 1;End;
If S='COS'Then Begin
R.Format:=DataSingle;
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not Nm(A)Then Exit;
Case(A.Format)of
DataInteger:R.Single:=Cos(A.Int);
DataLong:R.Single:=Cos(A.Long);
DataSingle:R.Single:=Cos(A.Single);
Else Begin;R.Format:=DataDouble;R.Double:=Cos(A.Double)End;
End;
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;
Goto 1;
End;
If S='CPU'Then Begin;R.Format:=DataInteger;R.Int:=CPU;Goto 1;End;
If S='CSRLIN'Then Begin;R.Format:=DataInteger;R.Int:=GetYTxtsPos;Goto 1;End;
If S='CTRLPRESS'Then Begin;R.Format:=DataInteger;R.Int:=Byte(CtrlPress);Goto 1;End;
Goto VarCheck;
_D: If S='DATE'Then Begin;R.Format:=DataInteger;R.Int:=Date;Goto 1;End;
If S='DIGITS'Then Begin;R.Format:=DataInteger;R.Int:=Digits;Goto 1;End;
If S='DIREXIST'Then Begin
If Not _Str2S(S)Then Exit;
R.Format:=DataInteger;R.Int:=Byte(DirExist(S));
Goto 1;
End;
If S='DOSVER'Then Begin;R.Format:=DataInteger;R.Int:=GetDosVer;Goto 1;End;
Goto VarCheck;
_E: If S='EMSEXIST'Then Begin;R.Format:=DataInteger;R.Int:=Byte(EmmExist);Goto 1;End;
If S='EMMNUMBERPAGE'Then Begin;R.Format:=DataInteger;R.Int:=EmmNumPage;Goto 1;End;
If S='EMSSEG'Then Begin;R.Format:=DataInteger;R.Int:=EmmSeg;Goto 1;End;
If S='EMSSIZE'Then Begin;R.Format:=DataInteger;R.Int:=EmmTotalSize;Goto 1;End;
If S='EXTSIZE'Then Begin;R.Format:=DataInteger;R.Int:=ExtBiosSizeK;Goto 1;End;
Goto VarCheck;
_F: If S='FILEEXIST'Then Begin
If Not _Str2S(S)Then Exit;
R.Format:=DataInteger;R.Int:=Byte(FileExist(S));
Goto 1;
End;
If S='FLOPPY'Then Begin;R.Format:=DataInteger;R.Int:=NmFloppyDsk;Goto 1;End;
If S='FRE'Then Begin;R.Format:=DataLong;R.Long:=SizeOf(Data)-CurData;Goto 1;End;
Goto VarCheck;
_G: If S='GRAF'Then Begin;R.Format:=DataInteger;R.Int:=Byte(IsGraf);Goto 1;End;
Goto VarCheck;
_H: If S='HARDDISK'Then Begin;R.Format:=DataInteger;R.Int:=NmHardDsk;Goto 1;End;
If S='HEIGHTCHR'Then Begin;R.Format:=DataInteger;R.Int:=HeightChr;Goto 1;End;
Goto VarCheck;
_I: If S='INP'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not Nm(A)Then Exit;
R.Format:=DataInteger;R.Int:=Port[A.Int];
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;
End;
If S='INSERT'Then Begin;R.Format:=DataInteger;R.Int:=Byte(GetModeIns);Goto 1;End;
If S='INSTR'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not _Str2S(S)Then Exit;
If PC^[IT]<>','Then Begin;RunXit:=VirguleExpected;Exit;End;
Inc(IT);
If Not _Str2S(S2)Then Exit;
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);R.Format:=DataInteger;R.Int:=Pos(S2,S);
Goto 1;
End;
If S='INSTAT'Then Begin
R.Format:=DataInteger;
If(KeyPress)Then R.Int:=-1 Else R.Int:=0;
Goto 1;
End;
If S='INTERRUPT'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not Nm(A)Then Exit;
If A.Format in[DataInteger,DataLong]Then Begin;RunXit:=TypeMistmatch;Exit;End;
GetIntVec(A.Int,Pointer(PC2));
R.Format:=DataLong;R.Long:=Long(PC2);
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;
End;
Goto VarCheck;
_J: If S='JOYBIOS'Then Begin;R.Format:=DataInteger;R.Int:=Byte(BiosJoy);Goto 1;End;
If S='JOYEXIST'Then Begin;R.Format:=DataInteger;R.Int:=Byte(JoyExist);Goto 1;End;
If S='JOYPORT'Then Begin;R.Format:=DataInteger;R.Int:=JoyPort;Goto 1;End;
Goto VarCheck;
_K: If S='KBDCTRL'Then Begin;R.Format:=DataInteger;R.Int:=KbdCtrl;Goto 1;End;
If S='KBDMODEL'Then Begin;R.Format:=DataInteger;R.Int:=KbdModel;Goto 1;End;
If S='KBDREADPORT'Then Begin;R.Format:=DataInteger;R.Int:=KbdReadPort;Goto 1;End;
If S='KEYPRESS'Then Begin
Ok:=KeyPress;
R.Format:=DataInteger;R.Int:=Byte(Ok);
Goto 1;
End;
Goto VarCheck;
_L: If S='LEN'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not _Str2S(S)Then Exit;
R.Format:=DataInteger;R.Int:=Length(S);
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;
End;
If S='LPT'Then Begin;R.Format:=DataInteger;R.Int:=NmLPT;Goto 1;End;
Goto VarCheck;
_M: If S='MONITOR'Then Begin;R.Format:=DataInteger;R.Int:=GetVideoMonitor;Goto 1;End;
If S='MONO'Then Begin;R.Format:=DataInteger;R.Int:=Byte(IsMono);Goto 1;End;
If S='MOUSE'Then Begin;R.Format:=DataInteger;R.Int:={$IFDEF Adele}Adele{$ELSE}Chantal{$ENDIF}.Mouse;Goto 1;End;
If S='MSBUTTON'Then Begin;R.Format:=DataInteger;R.Int:=MsButton;Goto 1;End;
If S='MSVER'Then Begin;R.Format:=DataInteger;R.Int:=MouseVer;Goto 1;End;
Goto VarCheck;
_N: If S='NEXTKEY'Then Begin;R.Format:=DataInteger;R.Int:=NxtKey;Goto 1;End;
If S='NUMLOCK'Then Begin;R.Format:=DataInteger;R.Int:=Byte(GetNmLck);Goto 1;End;
If S='NUMXTEXTS'Then Begin;R.Format:=DataInteger;R.Int:=NmXTxts;Goto 1;End;
If S='NUMYTEXTS'Then Begin;R.Format:=DataInteger;R.Int:=NmYTxts;Goto 1;End;
Goto VarCheck;
_O: Goto VarCheck;
_P: If S='POINT'Then Begin
SkipSpc;
If PC^[IT]<>'('Then Begin;RunXit:=OpenParExpected;Exit;End;
Inc(IT);
If Not Nm(A)Then Exit;
R.Format:=DataInteger;
If PC^[IT]=','Then Begin
Inc(IT);
If Not Nm(B)Then Exit;
R.Int:=GetPixel(A.Int,B.Int);
End
Else
Case Wd(A.Int)of
0,2:R.Int:=VidBnkSwitch.XL;
1,3:R.Int:=VidBnkSwitch.YL;
End;
If PC^[IT]<>')'Then Begin;RunXit:=CloseParExpected;Exit;End;
Inc(IT);Goto 1;