-
Notifications
You must be signed in to change notification settings - Fork 7
/
dosfetch.pas
176 lines (156 loc) · 3.53 KB
/
dosfetch.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
(* dosfetch - a neofetch clone for DOS
*
* Written by Leah Neukirchen <[email protected]>
*
* To the extent possible under law, the creator of this work has waived
* all copyright and related or neighboring rights to this work.
*)
program dosfetch;
uses crt, dos;
{
More ideas:
- uptime (hard)
- CPU details
}
function cmos(cmd: byte): byte;
begin
port[$70] := cmd;
cmos := port[$71];
end;
procedure base_memory;
var a : integer;
begin
asm
int $12;
mov a, ax;
end;
writeln(a, ' KB');
end;
procedure extended_memory;
var a, c, d : integer;
l : longint;
err : byte;
begin
err := 0;
asm
mov ah, $88;
int $15;
jnc @@skip;
mov err, ah;
@@skip:
mov a, ax;
end;
if err > 0 then
writeln('none') { XXX could be wrong on XT }
else begin
asm
clc;
mov ax, $E801;
int $15;
jnc @@skip;
mov err, ah;
@@skip:
mov c, cx;
mov d, dx;
end;
if err > 0 then
writeln(cmos($17) + 256*longint(cmos($18)), ' KB')
else
writeln(longint(c) + 64*longint(d), ' KB');
end;
end;
procedure disksize(disk: byte);
var a, b, c, d : word;
total, free : longint;
begin
asm
mov ah, $36;
mov dl, disk;
int $21;
mov a, ax;
mov b, bx;
mov c, cx;
mov d, dx;
end;
free := longint(a)*longint(c)*longint(b);
total := longint(a)*longint(c)*longint(d);
write(total div 1024 - free div 1024, '/', total div 1024, ' KB (');
writeln(round((free/total)*100), '% free)');
end;
procedure dosver;
var maj, min, ven : byte;
smaj, smin, sven : string;
begin
asm
mov ax, $3000;
int $21;
mov ven, bh;
mov ax, $3306;
int $21;
mov maj, bl;
mov min, bh;
end;
case ven of
$00 : write('IBM DOS ');
$FD : write('FreeDOS ');
$FF : write('MS DOS ');
else write('Unknown DOS ');
end;
writeln(maj, '.', min);
end;
procedure floppy;
var a : byte; f : integer;
begin
asm
int $11;
mov a, al;
end;
if ((a and $1) = $1) then
f := (a shr 6) + 1
else
f := 0;
writeln(f);
end;
procedure fpu;
var a : byte;
begin
asm
int $11;
mov a, al;
end;
if ((a and $2) = $2) then
writeln('YES')
else
writeln('no');
end;
procedure colorline(s : string);
var y, b, r : string;
begin
textcolor(yellow); write(copy(s, 1, 14));
textcolor(lightblue); write(copy(s, 15,14));
textcolor(lightred); write(copy(s, 29,14));
normvideo;
writeln;
end;
begin
clrscr;
writeln;
window(2, 2, 80, 25);
colorline('88888888ba, ,ad8888ba, ad88888ba ');
colorline('88 `"8b d8"'' `"8b d8" "8b ');
colorline('88 `8b d8'' `8b Y8, ');
colorline('88 88 88 88 `Y8aaaaa, ');
colorline('88 88 88 88 `"""""8b, ');
colorline('88 8P Y8, ,8P `8b ');
colorline('88 .a8P Y8a. .a8P Y8a a8P ');
colorline('88888888Y"'' `"Y8888Y"'' "Y88888P"');
window(45, 2, 80, 25);
textcolor(white); write('OS: '); normvideo; dosver;
textcolor(white); write('Shell: '); normvideo; writeln(getenv('COMSPEC'));
textcolor(white); write('Floppy drives: '); normvideo; floppy;
textcolor(white); write('Disk: '); normvideo; disksize(0);
textcolor(white); write('Base Memory: '); normvideo; base_memory;
textcolor(white); write('Ext. Memory: '); normvideo; extended_memory;
textcolor(white); write('Floating Point Unit: '); normvideo; fpu;
writeln;
end.