-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsysinfo.pas
186 lines (141 loc) · 4.95 KB
/
sysinfo.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
unit sysinfo;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, math, threads, retromalina, mwindows, simpleaudio, retromouse, platform, playerunit;
type TSysinfoThread=class (TThread)
private
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
var si:TWindow=nil;
tbb:array[0..15] of integer;
c6:int64=1;
avsct1,avspt1,sidtime1,av65021:array[0..59] of integer;
avsct:int64=0;
avspt:int64=0;
avall:int64=0;
avsid:int64=0;
implementation
constructor TSysinfoThread.create(CreateSuspended : boolean);
begin
FreeOnTerminate := True;
inherited Create(CreateSuspended);
end;
procedure TSysinfoThread.Execute;
var scr,i:integer;
wh:TWindow;
t:int64;
s1,s2,s3:string;
c1,l1,l2,l3:integer;
const cpuclock:integer=0;
cputemp:integer=0;
cnt:integer=0;
begin
ThreadSetAffinity(ThreadGetCurrent,4);
threadsleep(1);
for i:=0 to 15 do tbb[i]:=0;
si:=Twindow.create(300,290,'System status');
si.bg:=147;
si.cls(147);
si.move(400,500,300,290,0,0);
si.decoration.hscroll:=false;
si.decoration.vscroll:=false;
si.needclose:=false;
repeat
repeat threadsleep(1) until si.redraw;
c1:=framecnt mod 60;
si.box(0,0,300,300,147);
si.outtextxy(10,10,'CPU load: ',157);
i:=length(inttostr(round(100*avsct/16666)));
si.outtextxy(30,30,'screen: ',157);
si.outtextxy(180-8*i,30,inttostr(round(100*avsct/16666))+'%',157);
i:=length(inttostr(avsct));
si.outtextxy(230-8*i,30,inttostr(avsct)+' us',157);
si.outtextxy(30,48,'sprites: ',157);
i:=length(inttostr(round(100*avspt/16666)));
si.outtextxy(180-8*i,48,inttostr(round(100*avspt/16666))+'%',157);
i:=length(inttostr(avspt));
si.outtextxy(230-8*i,48,inttostr(avspt)+' us',157);
if sidcount<>0 then
begin
if filetype<3 then begin s1:='SID emulation:'; s2:=inttostr(avall); s3:=inttostr(round(100*avall/5000)); end
else if filetype=3 then begin s1:='WAV processing:'; s2:=inttostr(avall); s3:=inttostr(round(100*avall/siddelay)); end
else if filetype=4 then begin s1:='MP3 decoding:'; s2:=inttostr(mp3time); s3:=inttostr(round(100*mp3time/siddelay)); end
else if filetype=5 then begin s1:='MP2 decoding:'; s2:=inttostr(mp3time); s3:=inttostr(round(100*mp3time/siddelay)); end
else if filetype=6 then begin s1:='MOD decoding:'; s2:=inttostr(avall); s3:=inttostr(round(100*avall/siddelay)); end;
end;
if (filetype<3) and (avall=0) then begin s1:='Audio decoding:'; s2:='0'; s3:='0'; end;
l2:=length(s2)*8;
l3:=length(s3)*8;
si.outtextxy(30,66,s1,157);
si.outtextxy(180-l3,66, s3+'%',157);
si.outtextxy(230-l2,66, s2+' us',157);
s1:='6502 emulation:';
s2:=floattostrf((av6502/16),fffixed,4,1);
s3:=inttostr(round((100*av6502)/(16*2500)));
l2:=length(s2)*8;
l3:=length(s3)*8;
si.outtextxy(30,84,s1,157);
si.outtextxy(180-l3,84,s3+'%',157);
si.outtextxy(246-l2,84,s2+' us',157);
s1:=inttostr(cpuclock);
l1:=8*length(s1);
si.outtextxy(10,112,'CPU clock: ',157);
si.outtextxy(230-l1,112, s1+' MHz',157);
s1:=inttostr(cputemp);
l1:=8*length(s1);
si.outtextxy(10,132,'CPU temperature: ',157);
si.outtextxy(230-l1, 132, s1+' C',157);
si.outtextxy(10,152,'Sampling frequency: ',157);
s1:=inttostr(SA_getcurrentfreq);
l1:=8*length(s1);
si.outtextxy(230-l1,152,s1+ ' Hz',157);
si.outtextxy(10,172,'A4 base frequency: ',157);
si.outtextxy(206,172, inttostr(a1base)+' Hz',157);
s1:=inttostr(round(getdbvolume));
if (round(getdbvolume)<-72) then s1:='Mute' ;
l1:=8*length(s1);
if l1<32 then s1:=s1+' dB';
si.outtextxy(10,192,'Volume: ',157);
si.outtextxy(230-l1,192,s1,157);
si.outtextxy(10,212,'Mouse type:',157);
si.outtextxy(222,212,inttostr(mousetype),157);
si.outtextxy(10,232,'SID waveforms:',157);
si.outtextxy(10,252,'Windows time: ',157);
si.outtextxy(10,272,inttostr(et),157);
s1:=inttostr(wt);
l1:=8*length(s1);
si.outtextxy(230-l1, 252, s1+' us',157);
if channel1on=1 then si.outtextxyz(154,232,inttostr(peek(base+$d404)shr 4),122,2,1); // SID waveform
if channel2on=1 then si.outtextxyz(184,232,inttostr(peek(base+$d40b)shr 4),202,2,1);
if channel3on=1 then si.outtextxyz(214,232,inttostr(peek(base+$d412)shr 4),42,2,1);
//si.outtextxy(10,252,'windows count: '+inttostr(windowcount),157);
//si.outtextxy(10,272,'windows time: '+inttostr(windowtime),157);
if (cnt mod 60)=0 then
begin
for i:=0 to 14 do tbb[i]:=tbb[i+1];
tbb[15]:=TemperatureGetCurrent(0); // temperature
cputemp:=0; for i:=0 to 15 do cputemp+=tbb[i] ;
cputemp:=cputemp div 16000;
end;
if (cnt mod 120)=30 then cpuclock:=clockgetrate(8) div 1000000;
cnt+=1;
si.redraw:=false;
// compute average times
avsct1[c1]:=tim;
avspt1[c1]:=ts;
sidtime1[c1]:=sidtime;
if time6502>0 then c6+=1;
av65021[c1]:=time6502;
avsct:=0; for i:=0 to 59 do avsct+=avsct1[i]; avsct:=round(avsct/60);
avspt:=0; for i:=0 to 59 do avspt+=avspt1[i]; avspt:=round(avspt/60);
avall:=0; for i:=0 to 59 do avall+=sidtime1[i]; avall:=round(avall/60);
av6502:=0; for i:=0 to 59 do av6502+=av65021[i]; av6502:=round(av6502/60);
until terminated;
si.destroy;
si:=nil;
end;
end.