This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPROF.CPP
executable file
·148 lines (99 loc) · 2.74 KB
/
PROF.CPP
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
#include <stdlib.h>
#ifdef WIN95
#include "windows.h"
#endif
#ifdef DOS
extern unsigned ticks;
#endif
#include "types.h"
#include "prof.h"
#include "timing.h"
#include "message.h"
#include "r2img.h"
#include "font.h"
#include "dd.h"
anesprofile::anesprofile():
updatetimer(200), //update every 100 ticks
cycles(1000000.0)
{};
void anesprofile::update()
{
if (!updatetimer.check()) return; //dont update yet
//calculate number of seconds since last update
float dt=((float)updatetimer.dur)/((float)TIMERSPEED);
tiles.update(dt);
cycles.update(dt);
frames.update(dt);
vframes.update(dt);
cpu_timer.update(dt);
nesdraw_timer.update(dt);
gui_timer.update(dt);
input_timer.update(dt);
pageflip_timer.update(dt);
pageclear_timer.update(dt);
sound_timer.update(dt);
updatetimer.reset();
}
void anesprofile::draw(int x,int y)
{
/*
tiles.draw("tiles/sec:",x,y); y+=10;
frames.draw("frames/sec:",x,y); y+=10;
vframes.draw("vframes/sec:",x,y); y+=10;
cycles.draw("6502 Mhz:",x,y); y+=10;
y+=10;
pageclear_timer.draw("Pageclear:",x,y); y+=10;
pageflip_timer.draw("Pageflip:",x,y); y+=10;
nesdraw_timer.draw("NES rendering:",x,y); y+=10;
gui_timer.draw("GUI rendering:",x,y); y+=10;
cpu_timer.draw("6502 Emulation:",x,y); y+=10;
input_timer.draw("Input devices:",x,y); y+=10;
*/
pageclear_timer.drawmeter("Pageclear:",x,y,0xA0); y+=10;
pageflip_timer.drawmeter("Pageflip:",x,y,0xA0); y+=10;
gui_timer.drawmeter("GUI rendering:",x,y,0x40); y+=10;
input_timer.drawmeter("Input devices:",x,y,0x30); y+=15;
nesdraw_timer.drawmeter("NES rendering:",x,y,0x70); y+=10;
cpu_timer.drawmeter("6502 Emulation:",x,y,0x20); y+=10;
sound_timer.drawmeter("Sound:",x,y,0x10); y+=10;
// font[1]->printf(x,y,"%d",proftimer::gettime());
}
//-----------------------------------
//profcounter
void profcounter::draw(char *str,int x,int y)
{
int sw=font[0]->getwidth(str);
font[3]->draw(str,screen,x-sw-8,y);
font[1]->printf(x,y,"%.02f",getrate());
}
//------------------------------------
//proftimer
unsigned gettime()
{
#ifdef WIN95
return timeGetTime();
#endif
#ifdef DOS
return ticks*1000/TIMERSPEED;
#endif
}
void proftimer::draw(char *str,int x,int y)
{
int sw=font[0]->getwidth(str);
font[3]->draw(str,screen,x-sw-8,y);
font[1]->printf(x,y,"%5.02f%%",getrate());
}
extern int guienabled;
void proftimer::drawmeter(char *str,int x,int y,byte c)
{
if (guienabled)
{
int sw=font[0]->getwidth(str);
font[3]->draw(str,screen,x-sw-1,y);
}
int bw=(int)(getrate()+0.99)/2;
if (bw<0) bw=0;
if (bw>50) bw=50;
drawrect(screen,c+3,x,y+1,bw,8);
drawrect(screen,c+15,x+bw,y+1,50-bw,8);
}