-
Notifications
You must be signed in to change notification settings - Fork 1
/
utcheck.h
87 lines (75 loc) · 1.81 KB
/
utcheck.h
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
#ifndef __UTYPING_CHECK
#define __UTYPING_CHECK
#include "DxLib.h"
#include <vector>
using namespace std;
#define CCHECK_N_DATA (480/8)
#define CCHECK_WIDTH 250
#define CCHECK_SCALE ((1.0/60)/CCHECK_WIDTH)
class CCheck{
public:
CCheck();
void begin(int color);
void rap(int color);
void end();
void draw();
private:
void drawBar(int i, int y0, int y1);
private:
struct CheckData{
double time;
int color;
};
vector<CheckData> m_data[CCHECK_N_DATA];
int m_counter;
int m_color; /* 前の呼び出しで設定した色 */
LARGE_INTEGER m_begin;
LARGE_INTEGER m_freq;
};
CCheck g_check; /* debug */
CCheck::CCheck(){
m_counter = 0;
for(int i=0; i<CCHECK_N_DATA; i++){
m_data[i].clear();
}
QueryPerformanceFrequency(&m_freq);
}
void CCheck::begin(int color){
QueryPerformanceCounter(&m_begin);
m_data[m_counter].clear();
m_color = color;
}
void CCheck::rap(int color){
LARGE_INTEGER m_end;
QueryPerformanceCounter(&m_end);
CheckData cd;
cd.time = (double)(m_end.QuadPart - m_begin.QuadPart) / m_freq.QuadPart;
cd.color = m_color;
m_data[m_counter].push_back(cd);
m_color = color;
}
void CCheck::end(){
rap(0);
m_counter++;
if(m_counter == CCHECK_N_DATA){
m_counter = 0;
}
}
void CCheck::draw(){
for(int i=0; i<CCHECK_N_DATA; i++){
//drawBar((i + m_counter) % CCHECK_N_DATA, i * 8, (i + 1) * 8);
drawBar(i, i * 8, (i + 1) * 8);
}
DrawLine(CCHECK_WIDTH, 0, CCHECK_WIDTH, 480, GetColor(32, 32, 32));
DrawLine(CCHECK_WIDTH * 2, 0, CCHECK_WIDTH * 2, 480, GetColor(32, 32, 32));
}
void CCheck::drawBar(int i, int y0, int y1){
int last = 0;
int len = m_data[i].size();
for(int j=0; j<len; j++){
int tmp = (int)(m_data[i][j].time / CCHECK_SCALE);
DrawBox(last, y0, tmp, y1, m_data[i][j].color, TRUE);
last = tmp;
}
}
#endif