-
Notifications
You must be signed in to change notification settings - Fork 1
/
TEXTMODE.PAS
1135 lines (915 loc) · 19.6 KB
/
TEXTMODE.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
{$G-,N-,E-}
{*******************************************************
Textmode
Useful procedures and functions for fast drawing and
buffering in 80x25 text mode
Version 2.1 - 22.02.2021
Author: Jan Knipperts
*******************************************************
- Added compiler directives for compiling with TNDY Tracker
- Removed limits to be able to write outside the visible area
- Improved buffering
- Improved speed
(mit rep anweisung statt loop probieren!}
Unit Textmode;
interface
uses dos;
Function Detect_VidSeg : word;
Function Attr(fg,bg : byte; blink : boolean) : byte;
Function AttrMDA(underline,blink,bright : boolean) : Byte;
Procedure ChangeAttr(x,y,atrib : byte);
Procedure ChangeAttrVLine(x,y,l,atrib : byte);
Procedure ChangeAttrHLine(x,y,l,atrib : byte);
Procedure ChangeAttrBlock(x,y,x1,y1,atrib : byte);
Procedure ChangeChar(x,y,ch : byte);
Procedure Cursor(onoff : boolean);
Procedure Change_Cursor(start_line,bottom_line : byte);
Procedure FillMem(c : char; attr : byte; startoffset, count : word);
Procedure Box(xp,yp,xp1,yp1 : word; foreground, background : byte; slim : boolean; shadow : boolean);
Procedure Block(x,y,x1,y1,fg,bg : byte);
Procedure HLine(x,y,l,foreground,background : byte; c : char);
Procedure VLine(x,y,l,foreground,background : byte; c : char);
Procedure SetBorder(Color : Word);
Procedure InitMenuScreen(title : string; fc, bc : byte);
Procedure Centeredline(y,c,b : byte; title : string);
Procedure PutChar(x,y, fg, bg : byte; ch: Char);
Function GetChar(x,y: Byte): Char;
Function GetTextColor(x,y: Byte): Byte;
Function GetTextBackground(x,y: Byte): Byte;
Procedure Fastwrite(x,y,fg, bg : byte; s : string);
Procedure FastWriteNum(x, y, f, b: byte; num : longint);
Procedure CenteredText(y,c,b : byte; s : string);
Function GetX : byte;
Function GetY : byte;
Procedure GotoXy(x,y : byte);
Procedure Scrollup(lines,x,y,x1,y1 : byte);
Procedure Scrolldown(lines,x,y,x1,y1 : byte);
Procedure Write(s : string);
Procedure Writeln(s : string);
Procedure Textcolor(c : byte);
Procedure Textbackground(c : byte);
Procedure ClrScr;
Procedure ScreenFill(c : char; attr : byte);
Procedure SetWritePage(p : byte);
Procedure SetViewPage(p : byte);
Function Mouse_detected : boolean;
Function Mouse_Init : Boolean;
Procedure Mouse_SetHLimits(xmin, xmax : Word);
Procedure Mouse_SetVLimits(ymin, ymax : Word);
Procedure Mouse_Show;
Procedure Mouse_Hide;
Procedure Mouse_Read;
Procedure Mouse_SetPos(x, y : Byte);
Procedure ShadowScreen;
Procedure CopyBuffer(source,dest : pointer);
Procedure SwapBuffers(var buffer1,buffer2 : pointer);
Procedure DisplayBuffer(p : pointer);
Function GetDisplayBuffer : pointer;
Procedure Writeto(p : pointer);
Function GetWriteBuffer : pointer;
Procedure ChangeVSeg(seg : word);
function hex2dec(h:string) : byte;
Function hexn(h:byte):string;
function hexb(h:byte):string;
function hexw(h:word):string;
function addspace (base, b : word) : string;
function addzero (base, b : word) : string;
Function UpperCase(low : string) : string;
type
mousedata = record
nb,b : byte;
x,y : word;
mouse_there : boolean;
end;
screendata = record
maxX,
maxY,
page,
tc,
tbc : byte;
vidseg : word;
end;
var
mouse : mousedata;
txtscreen : screendata;
implementation
var
ocs,oce : byte;
writebuffer,
viewbuffer : pointer;
mi : pointer;
Function Detect_VidSeg : word;
begin
if Mem[$0000:$0449] = 7 then
Detect_VidSeg := $B000
else
Detect_VidSeg := $B800;
end;
Function Attr(fg,bg : byte; blink : boolean) :byte;
var a : byte;
begin
if txtscreen.VidSeg = $B800 then {Color display}
begin
a := fg or (bg shl 4);
if not blink then a := a and not $80;
end
else {Monochrome}
begin
a := AttrMDA(false,blink,false);
end;
attr := a;
end;
Function AttrMDA(underline,blink,bright : boolean) : Byte; {enhanced Attr function for monochrome display}
var a : byte;
begin
a := 7; {"Normal" setting for MDA = 00000111b}
if underline then a := 0; {Clear bits 2-0}
if bright then a := a or $8; {set bit 3}
if blink then a := a or $80; {set bit 7 for blink}
AttrMDA := a;
end;
Procedure ChangeAttr(x,y,atrib : byte);
assembler;
asm
push es
push si
push di
lea si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
xor ah,ah
xor bh,bh
mov al,y
dec al
mov bl,txtscreen.maxX
mul bl
mov bl,x
dec bl
add ax,bx
shl ax,1
inc ax
add di,ax
mov al,atrib
mov [es:di],al
pop di
pop si
pop es
end;
Procedure ChangeAttrHLine(x,y,l,atrib : byte);
assembler;
asm
push es
push si
push di
lea si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
xor ah,ah {calculate start offset}
xor bh,bh
mov al,y
dec al
mov bl,txtscreen.maxX
mul bl
mov bl,x
dec bl
add ax,bx
shl ax,1
inc ax
add di,ax
mov al,atrib
mov cl,l
xor ch,ch
cld
@XLoop:
stosb
inc di
loop @XLoop
pop di
pop si
pop es
end;
Procedure ChangeAttrVLine(x,y,l,atrib : byte);
assembler;
asm
push es
push si
push di
lea si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
xor ah,ah {calculate start offset}
xor bh,bh
mov al,y
dec al
mov bl,txtscreen.maxX
mul bl
mov bl,x
dec bl
add ax,bx
shl ax,1
inc ax
add di,ax
mov al,txtscreen.maxX
mov bl,2
mul bl
mov bx,ax
mov al,atrib
mov cl,l
xor ch,ch
cld
@YLoop:
stosb
add di,bx
dec di
loop @YLoop
pop di
pop si
pop es
end;
Procedure ChangeAttrBlock(x,y,x1,y1,atrib : byte);
var yc : byte;
begin
for yc := y to y1 do
ChangeAttrHLine(x,yc,(x1-x),atrib);
end;
Procedure ChangeChar(x,y,ch : byte);
assembler;
asm
push es
push si
push di
lea si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
xor ah,ah
xor bh,bh
mov al,y
dec al
mov bl,txtscreen.maxX
mul bl
mov bl,x
dec bl
add ax,bx
shl ax,1
add di,ax
mov al,ch
mov [es:di],al
pop di
pop si
pop es
end;
Procedure PutChar(x,y, fg, bg : byte; ch: Char);
begin
if x > 0 then x := x-1;
if y > 0 then y := y-1;
mem[seg(writebuffer^):ofs(writebuffer^)+((y*txtscreen.maxX)+x) shl 1] := ord(ch);
mem[seg(writebuffer^):ofs(writebuffer^)+(((y*txtscreen.maxX)+x) shl 1)+1] := Attr(fg,bg,false);
end;
Function GetChar(x,y: Byte): Char;
begin
if x > 0 then x := x-1;
if y > 0 then y := y-1;
GetChar:=Char(mem[seg(writebuffer^):ofs(writebuffer^)+((y*txtscreen.maxX)+x) shl 1]);
end;
Function GetTextColor(x,y: Byte): Byte;
begin
if x > 0 then x := x-1;
if y > 0 then y := y-1;
GetTextColor:=mem[seg(writebuffer^):ofs(writebuffer^)+(((y*txtscreen.maxX)+x) shl 1)+1] and $f;
end;
Function GetTextBackground(x,y: Byte): Byte;
begin
if x > 0 then x := x-1;
if y > 0 then y := y-1;
GetTextBackground:=mem[seg(writebuffer^):ofs(writebuffer^)+(((y*txtscreen.maxX)+x) shl 1)+1] or $f;
end;
Procedure Cursor(onoff : boolean);
assembler;
asm
cmp onoff,true
je @on
mov ah,3 {save old cursor shape}
mov bh,0
int 10h
mov ocs,ch
mov oce,cl
mov ah,1 {Disable cursor}
mov ch,32
mov cl,7
int 10h
jmp @exit
@on:
mov ah,1 {Restore last cursor shape}
mov ch,ocs
mov cl,oce
int 10h
jmp @exit
@EXIT:
end;
Procedure Change_Cursor(start_line,bottom_line : byte);
assembler;
asm {0,7 shows box-shaped text cursor}
mov ch,start_line
mov cl,bottom_line
mov ah,1
int 10h
end;
Procedure Fastwrite(x,y,fg, bg : byte; s : string);
var c,a : byte;
offset : word;
begin
a := Attr(fg,bg,false);
if x > 0 then x := x-1;
if y > 0 then y := y-1;
offset := ofs(writebuffer^)+((y*txtscreen.maxX)+x) shl 1;
for c := 1 to length(s) do
begin
memw[seg(writebuffer^):offset] := (a shl 8)+ord(s[c]);
offset := offset + 2;
end;
end;
Procedure CenteredText(y,c,b : byte; s : string);
begin
fastwrite(40-(length(s) div 2),y,c,b,s);
end;
Procedure Block(x,y,x1,y1,fg,bg : byte);
var yc,a : byte;
begin
a := Attr(fg,bg,false);
for yc := y to y1 do
begin
fillmem(' ',a,(((yc-1)*txtscreen.maxX)+(x-1)) shl 1,x1-x);
end;
end;
Procedure HLine(x,y,l,foreground,background : byte; c : char);
begin
fillmem(c,Attr(foreground,background,false),(((y-1)*txtscreen.maxX)+(x-1)) shl 1,l);
end;
Procedure VLine(x,y,l,foreground,background : byte; c : char);
var cnt : byte;
begin
for cnt := 0 to l-1 do
putchar(x,y+cnt,foreground,background,c);
end;
Procedure Box(xp,yp,xp1,yp1 : word; foreground, background : byte; slim : boolean; shadow : boolean);
begin
Block(xp,yp,xp1,yp1,foreground,background);
if slim then
begin
HLine(xp,yp,xp1-xp,foreground,background,'Ä');
HLine(xp,yp1,xp1-xp,foreground,background,'Ä');
Vline(xp,yp,yp1-yp,foreground,background,'³');
Vline(xp1,yp,yp1-yp,foreground,background,'³');
putchar(xp,yp,foreground,background,'Ú');
putchar(xp1,yp,foreground,background,'¿');
putchar(xp,yp1,foreground,background,'À');
putchar(xp1,yp1,foreground,background,'Ù');
end
else
begin
HLine(xp,yp,xp1-xp,foreground,background,'Í');
HLine(xp,yp1,xp1-xp,foreground,background,'Í');
Vline(xp,yp,yp1-yp,foreground,background,'º');
Vline(xp1,yp,yp1-yp,foreground,background,'º');
putchar(xp,yp,foreground,background,'É');
putchar(xp1,yp,foreground,background,'»');
putchar(xp,yp1,foreground,background,'È');
putchar(xp1,yp1,foreground,background,'¼');
end;
if shadow then
begin
ChangeAttrHLine(xp+1,yp1+1,(xp1-xp)+1,8);
ChangeAttrVLine(xp1+1,yp+1,(yp1-yp)+1,8);
end;
end;
Procedure SetBorder(Color : Word);
Assembler;
asm
mov ax, 0b00h
mov bx, Color
int 10h
end;
Procedure FillMem(c : char; attr : byte; startoffset, count : word);
{Fast 16-bit screenmemory filler}
assembler;
asm
push es
push di
lea si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
add di,startoffset
mov al,c
mov ah,attr
mov cx,count
cld
@Loop:
stosw
loop @Loop
pop di
pop es
end;
Procedure Screenfill(c : char; attr : byte);
{Fast 16-bit screenfill}
assembler;
asm
push es
push di
lea si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
mov al,c
mov ah,attr
mov cx,2000 {4000 / 2}
cld
@Loop:
stosw
loop @Loop
pop di
pop es
end;
Procedure ClrScr;
begin
scrollup(0,0,0,79,24);
gotoxy(1,1);
end;
Procedure Centeredline(y,c,b : byte; title : string);
var z,x : byte;
begin
z := 1;
for x := 1 to txtscreen.maxX do
begin
if (x >= ((txtscreen.maxX div 2)-(length(title) div 2))) and (z <= length(title)) then
begin
putchar(x,y,c,b,title[z]);
inc(z);
end
else
begin
putchar(x,y,c,b,' ');
end;
end;
end;
Procedure InitMenuScreen(title : string; fc, bc : byte);
var z : byte;
begin
z := 0 or 7 and not $80; {Textfarbe 7, Hintergrund 0, blinken aus}
ScreenFill('±',z);
Centeredline(1,fc,bc,title);
end;
Function Mouse_detected : boolean;
begin
GetIntVec($33, mi);
If (mi = NIL) then
mouse_detected := False
else
if (Byte(mi^) = $CF) then mouse_detected := False
else
mouse_detected := True;
end;
Function Mouse_Init : Boolean;
assembler;
asm
xor ax,ax
int $33
cmp ax,0
je @failed
mov mouse.nb,bl
mov al,1
jmp @quit
@failed:
xor al,al
mov mouse.nb,al
@quit:
end;
Procedure Mouse_SetHLimits(xmin, xmax : Word);
{ set horizontal limits }
assembler;
asm
cmp mouse.mouse_there,0
je @fail
mov ax,7
mov cx,xmin
mov dx,xmax
int $33
@fail:
end;
Procedure Mouse_SetVLimits(ymin, ymax : Word);
{ set vertical limits }
assembler;
asm
cmp mouse.mouse_there,0
je @fail
mov ax,8
mov cx,ymin
mov dx,ymax
int $33
@fail:
end;
Procedure Mouse_Show;
assembler;
asm
cmp mouse.mouse_there,0
je @fail
mov ax,1
int $33
@fail:
end;
Procedure Mouse_Hide;
assembler;
asm
cmp mouse.mouse_there,0
je @fail
mov ax,2
int $33
@fail:
end;
Procedure Mouse_Read;
assembler;
asm
cmp mouse.mouse_there,0
je @fail
mov ax,3
int $33
mov mouse.x,cx
mov mouse.y,dx
mov mouse.b,bl
@fail:
end;
Procedure Mouse_SetPos(x, y : Byte);
assembler;
asm
cmp mouse.mouse_there,0
je @fail
mov ax,4
int $33
mov mouse.x,cx
mov mouse.y,dx
@fail:
end;
Procedure GotoXY(x,y : byte);
begin
if x > 0 then x := x-1;
if y > 0 then y := y-1;
asm
mov ah,2h
mov bh,txtscreen.page
mov dh,y
mov dl,x
int 10h
end;
end;
function GetX : byte;
var x : byte;
begin
asm
mov ah,3
mov bh,txtscreen.page
int 10h
mov x,dl
end;
GetX := x+1;
end;
function GetY : byte;
var y : byte;
begin
asm
mov ah,3
mov bh,txtscreen.page
int 10h
mov y,dh
end;
GetY := Y+1;
end;
Procedure Textcolor(c : byte);
begin
txtscreen.tc := c;
end;
Procedure Textbackground(c : byte);
begin
txtscreen.tbc := c;
end;
Procedure Scrolldown(lines,x,y,x1,y1 : byte);
var a : byte;
begin
a := Attr(txtscreen.tc,txtscreen.tbc,false);
asm
mov ah,7
mov al,lines
mov bh,a
mov cl,x
mov ch,y
mov dl,x1
mov dh,y1
int 10h
end;
end;
Procedure Scrollup(lines,x,y,x1,y1 : byte);
var a : byte;
begin
a := Attr(txtscreen.tc,txtscreen.tbc,false);
asm
mov ah,6
mov al,lines
mov bh,a
mov cl,x
mov ch,y
mov dl,x1
mov dh,y1
int 10h
end;
end;
Procedure FastWriteNum(x, y, f, b: byte; num : longint);
{ Does a direct video write -- extremely fast.
X, Y = screen location of first byte;
Num = Number to display;
F = foreground color;
B = background color. }
var s : string;
c : byte;
begin
str(num,s);
for c := 1 to length(s) do
begin
putchar(x,y,f,b,s[c]);
inc(x);
end;
end;
Procedure Write(s : string);
var cnt,x,y : word;
begin
x := GetX;
y := GetY;
for cnt := 1 to length(s) do
begin
putchar(x,y,txtscreen.tc,txtscreen.tbc,s[cnt]);
inc(x);
if x = 81 then
begin
x := 1;
if y = 25 then
begin
scrollup(1,0,0,79,24);
end
else
begin
inc(y);
end;
end;
end;
gotoxy(x,y);
end;
Procedure Writeln(s : string);
var y : byte;
begin
write(s);
y := getY;
if y = 25 then
begin
scrollup(1,0,0,79,24);
gotoxy(1,25);
end
else
begin
gotoxy(1,y+1);
end;
end;
Procedure SetWritePage(p : byte);
begin
txtscreen.page := p;
end;
Procedure SetViewPage(p : byte);
assembler;
asm
mov ah,5;
mov al,p
int 10h
end;
Procedure ShadowScreen;
assembler;
asm
push ds
push es
push si
push di
lds si,writebuffer
mov es,[ds:si+2]
mov di,[ds:si]
inc di
xor al,al
mov al,8
mov cx,2000 {4000 / 2}
cld
@CopyLoop:
stosb
inc di
loop @CopyLoop
pop di
pop si
pop es
pop ds
end;
function hex_char(Zeichen :char):byte;
begin
zeichen := upcase(zeichen);
case zeichen of
'0': hex_char := 0;
'1': hex_char := 1;
'2': hex_char := 2;
'3': hex_char := 3;
'4': hex_char := 4;
'5': hex_char := 5;
'6': hex_char := 6;
'7': hex_char := 7;
'8': hex_char := 8;
'9': hex_char := 9;
'A': hex_char := 10;
'B': hex_char := 11;
'C': hex_char := 12;
'D': hex_char := 13;
'E': hex_char := 14;
'F': hex_char := 15;
end;
end;
function hex2dec(h:string) : byte;
var hexa :byte;
begin
hexa := 0;
hexa := hexa+hex_char(h[2]);
hexa := hexa+hex_char(h[1])*16;
hex2dec := hexa;
end;
Function hexn(h:byte):string;
const
hexChars: array [0..$F] of Char =
'0123456789ABCDEF';
begin
hexn := hexChars[h and $F];
end;
function hexb(h:byte):string;
const
hexChars: array [0..$F] of Char =
'0123456789ABCDEF';
begin
hexb := hexChars[h shr 4]+
hexChars[h and $F];
end;
function hexw(h:word):string;
const
hexChars: array [0..$F] of Char =
'0123456789ABCDEF';
begin
hexw := hexChars[hi(h) shr 4]+
hexChars[hi(h) and $F]+
hexChars[Lo(h) shr 4]+
hexChars[Lo(h) and $F];
end;
function addspace (base, b : word) : string;
var
c2 : string;
begin
str(b, c2);
case base of
10 :
if b < 10 then c2 := ' ' + c2;
100 :
begin
if b < 10 then
c2 := ' ' + c2;
if (b >= 10) and (b < 100) then
c2 := ' ' + c2;
end;
1000 :
begin
if b < 10 then
c2 := ' ' + c2;
if (b >= 10) and (b < 100) then
c2 := ' ' + c2;
if (b >= 100) and (b < 1000) then
c2 := ' ' + c2;
end;
10000 :
begin
if b < 10 then
c2 := ' ' + c2;
if (b >= 10) and (b < 100) then
c2 := ' ' + c2;
if (b >= 100) and (b < 1000) then
c2 := ' ' + c2;
if (b >= 1000) and (b < 10000) then
c2 := ' ' + c2;
end;
end;
addspace := c2;
end; {addspace}
function addzero (base, b : word) : string;
var
c2 : string;
begin
STR (b, c2);