📄 meter.c
字号:
RGB16(236, 0,255),
RGB16(237, 0,255),
RGB16(238, 0,255),
RGB16(239, 0,255),
RGB16(240, 0,255),
RGB16(241, 0,255),
RGB16(242, 0,255),
RGB16(243, 0,255),
RGB16(244, 0,255),
RGB16(245, 0,255),
RGB16(246, 0,255),
RGB16(247, 0,255),
RGB16(248, 0,255),
RGB16(249, 0,255),
RGB16(250, 0,255),
RGB16(251, 0,255),
RGB16(252, 0,255),
RGB16(253, 0,255),
RGB16(254, 0,255),
RGB16(255, 0,255),
RGB16(255, 0,254),
RGB16(255, 0,253),
RGB16(255, 0,252),
RGB16(255, 0,251),
RGB16(255, 0,250),
RGB16(255, 0,249),
RGB16(255, 0,248),
RGB16(255, 0,247),
RGB16(255, 0,246),
RGB16(255, 0,245),
RGB16(255, 0,244),
RGB16(255, 0,243),
RGB16(255, 0,242),
RGB16(255, 0,241),
RGB16(255, 0,240),
RGB16(255, 0,239),
RGB16(255, 0,238),
RGB16(255, 0,237),
RGB16(255, 0,236),
RGB16(255, 0,235),
RGB16(255, 0,234),
RGB16(255, 0,233),
RGB16(255, 0,232),
RGB16(255, 0,231),
RGB16(255, 0,230),
RGB16(255, 0,229),
RGB16(255, 0,228),
RGB16(255, 0,227),
RGB16(255, 0,226),
RGB16(255, 0,225),
RGB16(255, 0,224),
RGB16(255, 0,223),
RGB16(255, 0,222),
RGB16(255, 0,221),
RGB16(255, 0,220),
RGB16(255, 0,219),
RGB16(255, 0,218),
RGB16(255, 0,217),
RGB16(255, 0,216),
RGB16(255, 0,215),
RGB16(255, 0,214),
RGB16(255, 0,213),
RGB16(255, 0,212),
RGB16(255, 0,211),
RGB16(255, 0,210),
RGB16(255, 0,209),
RGB16(255, 0,208),
RGB16(255, 0,207),
RGB16(255, 0,206),
RGB16(255, 0,205),
RGB16(255, 0,204),
RGB16(255, 0,203),
RGB16(255, 0,202),
RGB16(255, 0,201),
RGB16(255, 0,200),
RGB16(255, 0,199),
RGB16(255, 0,198),
RGB16(255, 0,197),
RGB16(255, 0,196),
RGB16(255, 0,195),
RGB16(255, 0,194),
RGB16(255, 0,193),
RGB16(255, 0,192),
RGB16(255, 0,191),
RGB16(255, 0,190),
RGB16(255, 0,189),
RGB16(255, 0,188),
RGB16(255, 0,187),
RGB16(255, 0,186),
RGB16(255, 0,185),
RGB16(255, 0,184),
RGB16(255, 0,183),
RGB16(255, 0,182),
RGB16(255, 0,181),
RGB16(255, 0,180),
RGB16(255, 0,179),
RGB16(255, 0,178),
RGB16(255, 0,177),
RGB16(255, 0,176),
RGB16(255, 0,175),
RGB16(255, 0,174),
RGB16(255, 0,173),
RGB16(255, 0,172),
RGB16(255, 0,171),
RGB16(255, 0,170),
RGB16(255, 0,169),
RGB16(255, 0,168),
RGB16(255, 0,167),
RGB16(255, 0,166),
RGB16(255, 0,165),
RGB16(255, 0,164),
RGB16(255, 0,163),
RGB16(255, 0,162),
RGB16(255, 0,161),
RGB16(255, 0,160),
RGB16(255, 0,159),
RGB16(255, 0,158),
RGB16(255, 0,157),
RGB16(255, 0,156),
RGB16(255, 0,155),
RGB16(255, 0,154),
RGB16(255, 0,153),
RGB16(255, 0,152),
RGB16(255, 0,151),
RGB16(255, 0,150),
RGB16(255, 0,149),
RGB16(255, 0,148),
RGB16(255, 0,147),
RGB16(255, 0,146),
RGB16(255, 0,145),
RGB16(255, 0,144),
RGB16(255, 0,143),
RGB16(255, 0,142),
RGB16(255, 0,141),
RGB16(255, 0,140),
RGB16(255, 0,139),
RGB16(255, 0,138),
RGB16(255, 0,137),
RGB16(255, 0,136),
RGB16(255, 0,135),
RGB16(255, 0,134),
RGB16(255, 0,133),
RGB16(255, 0,132),
RGB16(255, 0,131),
RGB16(255, 0,130),
RGB16(255, 0,129),
RGB16(255, 0,128),
RGB16(255, 0,127),
RGB16(255, 0,126),
RGB16(255, 0,125),
RGB16(255, 0,124),
RGB16(255, 0,123),
RGB16(255, 0,122),
RGB16(255, 0,121),
RGB16(255, 0,120),
RGB16(255, 0,119),
RGB16(255, 0,118),
RGB16(255, 0,117),
RGB16(255, 0,116),
RGB16(255, 0,115),
RGB16(255, 0,114),
RGB16(255, 0,113),
RGB16(255, 0,112),
RGB16(255, 0,111),
RGB16(255, 0,110),
RGB16(255, 0,109),
RGB16(255, 0,108),
RGB16(255, 0,107),
RGB16(255, 0,106),
RGB16(255, 0,105),
RGB16(255, 0,104),
RGB16(255, 0,103),
RGB16(255, 0,102),
RGB16(255, 0,101),
RGB16(255, 0,100),
RGB16(255, 0, 99),
RGB16(255, 0, 98),
RGB16(255, 0, 97),
RGB16(255, 0, 96),
RGB16(255, 0, 95),
RGB16(255, 0, 94),
RGB16(255, 0, 93),
RGB16(255, 0, 92),
RGB16(255, 0, 91),
RGB16(255, 0, 90),
RGB16(255, 0, 89),
RGB16(255, 0, 88),
RGB16(255, 0, 87),
RGB16(255, 0, 86),
RGB16(255, 0, 85),
RGB16(255, 0, 84),
RGB16(255, 0, 83),
RGB16(255, 0, 82),
RGB16(255, 0, 81),
RGB16(255, 0, 80),
RGB16(255, 0, 79),
RGB16(255, 0, 78),
RGB16(255, 0, 77),
RGB16(255, 0, 76),
RGB16(255, 0, 75),
RGB16(255, 0, 74),
RGB16(255, 0, 73),
RGB16(255, 0, 72),
RGB16(255, 0, 71),
RGB16(255, 0, 70),
RGB16(255, 0, 69),
RGB16(255, 0, 68),
RGB16(255, 0, 67),
RGB16(255, 0, 66),
RGB16(255, 0, 65),
RGB16(255, 0, 64),
RGB16(255, 0, 63),
RGB16(255, 0, 62),
RGB16(255, 0, 61),
RGB16(255, 0, 60),
RGB16(255, 0, 59),
RGB16(255, 0, 58),
RGB16(255, 0, 57),
RGB16(255, 0, 56),
RGB16(255, 0, 55),
RGB16(255, 0, 54),
RGB16(255, 0, 53),
RGB16(255, 0, 52),
RGB16(255, 0, 51),
RGB16(255, 0, 50),
RGB16(255, 0, 49),
RGB16(255, 0, 48),
RGB16(255, 0, 47),
RGB16(255, 0, 46),
RGB16(255, 0, 45),
RGB16(255, 0, 44),
RGB16(255, 0, 43),
RGB16(255, 0, 42),
RGB16(255, 0, 41),
RGB16(255, 0, 40),
RGB16(255, 0, 39),
RGB16(255, 0, 38),
RGB16(255, 0, 37),
RGB16(255, 0, 36),
RGB16(255, 0, 35),
RGB16(255, 0, 34),
RGB16(255, 0, 33),
RGB16(255, 0, 32),
RGB16(255, 0, 31),
RGB16(255, 0, 30),
RGB16(255, 0, 29),
RGB16(255, 0, 28),
RGB16(255, 0, 27),
RGB16(255, 0, 26),
RGB16(255, 0, 25),
RGB16(255, 0, 24),
RGB16(255, 0, 23),
RGB16(255, 0, 22),
RGB16(255, 0, 21),
RGB16(255, 0, 20),
RGB16(255, 0, 19),
RGB16(255, 0, 18),
RGB16(255, 0, 17),
RGB16(255, 0, 16),
RGB16(255, 0, 15),
RGB16(255, 0, 14),
RGB16(255, 0, 13),
RGB16(255, 0, 12),
RGB16(255, 0, 11),
RGB16(255, 0, 10),
RGB16(255, 0, 9),
RGB16(255, 0, 8),
RGB16(255, 0, 7),
RGB16(255, 0, 6),
RGB16(255, 0, 5),
RGB16(255, 0, 4),
RGB16(255, 0, 3),
RGB16(255, 0, 2),
RGB16(255, 0, 1),
};
void
Draw_Text(unsigned short *pusBuffer, unsigned long ulX, unsigned long ulY,
unsigned short usColor, char *pcString)
{
unsigned long ulDX, ulDY;
while(*pcString)
{
for(ulDY = 0; ulDY < 16; ulDY++)
{
for(ulDX = 0; ulDX < 8; ulDX++)
{
if(fontdata_8x16[(*pcString * 16) + ulDY] & (1 << (7 - ulDX)))
{
pusBuffer[((ulY + ulDY) * 640) + ulX + (ulDX * 2)] = usColor;
pusBuffer[((ulY + ulDY) * 640) + ulX + (ulDX * 2) + 1] = usColor;
}
}
}
pcString++;
ulX += 16;
}
}
unsigned long
printheader(unsigned long ulPoints, int crunch)
{
char pcString[256];
sprintf(pcString, "%s Bezier loop: 0/sec",
crunch ? "Crunch" : "Soft-float");
Draw_Text(pusFrame, 320 - (strlen(pcString) * 8), 8, 0xffff, pcString);
memset(pusFrame + (640 * 32), 0xff, 640 * 2 * 2);
DrawBezierIcon();
return(320 - (strlen(pcString) * 8) + ((strlen(pcString) - 7) * 16));
}
volatile int g_bActive = 0; // Is thread active ?
int meter_main(int crunch , unsigned long ulDepth, unsigned long ulPoints)
{
long plPointsX[MAXDEPTH][MAXPOINTS + 2];
long plPointsY[MAXDEPTH][MAXPOINTS + 2];
long plDirX[MAXPOINTS], plDirY[MAXPOINTS];
unsigned long ulIndex, ulColor, ulStep, ulNext, ulPos;
int c;
char pcString[256];
time_t t1, t2;
if(crunch)
{
pfnBezier = DrawBezierCrunch;
}
else
{
pfnBezier = DrawBezier;
}
fb_init();
ulPos = printheader(ulPoints, crunch);
memset(plPointsX, 0, sizeof(plPointsX));
memset(plPointsY, 0, sizeof(plPointsY));
for(ulIndex = 0; ulIndex < ulPoints; ulIndex++)
{
plPointsX[0][ulIndex] = (rand() >> 5) % 640;
plPointsY[0][ulIndex] = 40 + ((rand() >> 6) % 440);
do
{
plDirX[ulIndex] = 8 - ((rand() >> 12) << 1);
}
while(plDirX[ulIndex] == 0);
do
{
plDirY[ulIndex] = 8 - ((rand() >> 12) << 1);
}
while(plDirY[ulIndex] == 0);
}
plPointsX[0][ulPoints] = plPointsX[0][0];
plPointsY[0][ulPoints] = plPointsY[0][0];
plPointsX[0][ulPoints + 1] = plPointsX[0][1];
plPointsY[0][ulPoints + 1] = plPointsY[0][1];
ulColor = 0;
ulStep = 0;
c = 0;
t1 = GetTickCount()/1000;
g_bActive=1;
while(g_bActive)
{
ulNext = (ulStep + 1) % ulDepth;
DrawBand(plPointsX[ulStep], plPointsY[ulStep], ulPoints,
pusColors[ulColor]);
DrawBand(plPointsX[ulNext], plPointsY[ulNext], ulPoints, 0);
ulColor++;
if(ulColor == (sizeof(pusColors) / sizeof(pusColors[0])))
{
ulColor = 0;
}
for(ulIndex = 0; ulIndex < ulPoints; ulIndex++)
{
plPointsX[ulNext][ulIndex] = (plPointsX[ulStep][ulIndex] +
plDirX[ulIndex]);
if(plPointsX[ulNext][ulIndex] < 0)
{
plPointsX[ulNext][ulIndex] = 0;
do
{
plDirX[ulIndex] = (rand() >> 13) << 1;
}
while(plDirX[ulIndex] == 0);
}
if(plPointsX[ulNext][ulIndex] >= 640)
{
plPointsX[ulNext][ulIndex] = 639;
do
{
plDirX[ulIndex] = 0 - ((rand() >> 13) << 1);
}
while(plDirX[ulIndex] == 0);
}
plPointsY[ulNext][ulIndex] = (plPointsY[ulStep][ulIndex] +
plDirY[ulIndex]);
if(plPointsY[ulNext][ulIndex] < 40)
{
plPointsY[ulNext][ulIndex] = 40;
do
{
plDirY[ulIndex] = (rand() >> 13) << 1;
}
while(plDirY[ulIndex] == 0);
}
if(plPointsY[ulNext][ulIndex] >= 480)
{
plPointsY[ulNext][ulIndex] = 479;
do
{
plDirY[ulIndex] = 0 - ((rand() >> 13) << 1);
}
while(plDirY[ulIndex] == 0);
}
}
plPointsX[ulNext][ulPoints] = plPointsX[ulNext][0];
plPointsY[ulNext][ulPoints] = plPointsY[ulNext][0];
plPointsX[ulNext][ulPoints + 1] = plPointsX[ulNext][1];
plPointsY[ulNext][ulPoints + 1] = plPointsY[ulNext][1];
ulStep++;
if(ulStep == ulDepth)
{
ulStep = 0;
}
c++;
t2 = GetTickCount()/1000;
if(t1 != t2)
{
for(t1 = 8; t1 < 24; t1++)
{
memset(pusFrame + (t1 * 640) + ulPos, 0, 3 * 32);
}
sprintf(pcString, "%3d", c);
Draw_Text(pusFrame, ulPos, 8, 0xffff, pcString);
c = 0;
t1 = t2;
}
}
fb_cleanup();
return(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -