7 // TinyFPS, just a minimal fraps like font to show FPS during the demo and not just after.
8 // I'll be using it in my effects for my performance test purposes, just adding it here.
9 // Maybe it would be nice if initFpsFonts would be called in demo.c once but I avoided touching that code.
12 1110 0010 1110 1110 1010 1110 1110 1110 1110 1110
13 1010 0010 0010 0010 1010 1000 1000 0010 1010 1010
14 1010 0010 1110 0110 1110 1110 1110 0010 1110 1110
15 1010 0010 1000 0010 0010 0010 1010 0010 1010 0010
16 1110 0010 1110 1110 0010 1110 1110 0010 1110 1110
19 static const unsigned char miniDecimalData[] = { 0xE2, 0xEE, 0xAE, 0xEE, 0xEE,
20 0xA2, 0x22, 0xA8, 0x82, 0xAA,
21 0xA2, 0xE6, 0xEE, 0xE2, 0xEE,
22 0xA2, 0x82, 0x22, 0xA2, 0xA2,
23 0xE2, 0xEE, 0x2E, 0xE2, 0xEE };
25 static unsigned short miniDecimalFonts[FPS_FONT_NUM_PIXELS];
27 static unsigned long startingFpsTime = 0;
28 static int fpsFontsInit = 0;
29 static int nFrames = 0;
33 if (fpsFontsInit == 0)
35 unsigned char miniDecimalPixels[FPS_FONT_NUM_PIXELS];
39 for (i = 0; i < FPS_FONT_NUM_PIXELS / 8; i++)
41 unsigned char d = miniDecimalData[i];
42 for (j = 0; j < 8; j++)
44 unsigned char c = (d & 0x80) >> 7;
45 miniDecimalPixels[k++] = c;
51 for (n = 0; n < FPS_FONTS_NUM; n++)
53 for (y = 0; y < FPS_FONT_HEIGHT; y++)
55 for (x = 0; x < FPS_FONT_WIDTH; x++)
57 miniDecimalFonts[i++] = miniDecimalPixels[n * FPS_FONT_WIDTH + x + y * FPS_FONT_WIDTH * FPS_FONTS_NUM] * 0xFFFF;
66 static void drawFont(unsigned char decimal, int posX, int posY, unsigned char zoom, unsigned short *vram)
71 unsigned short *fontData = (unsigned short*)&miniDecimalFonts[decimal * FPS_FONT_WIDTH * FPS_FONT_HEIGHT];
73 vram += posY * fb_width + posX;
75 if (zoom < 1) zoom = 1;
76 if (zoom > 4) zoom = 4;
78 for (y = 0; y<FPS_FONT_HEIGHT; y++)
80 for (x = 0; x<FPS_FONT_WIDTH; x++)
86 for (j=0; j<zoom; j++)
88 for (k=0; k<zoom; k++)
90 *(vram + j * fb_width + k) ^= c;
96 vram += (-FPS_FONT_WIDTH * zoom + fb_width * zoom);
100 static void drawDecimal(unsigned int number, int posX, int posY, unsigned char zoom, unsigned short *vram)
105 sprintf(buffer, "%d", number);
107 while(i < 8 && buffer[i] != 0)
109 drawFont(buffer[i] - 48, posX + i * zoom * FPS_FONT_WIDTH, posY, zoom, vram);
114 void drawFps(unsigned short *vram)
116 unsigned long dt = time_msec - startingFpsTime;
122 fps = (nFrames * 1000) / dt;
123 startingFpsTime = time_msec;
126 //drawDecimal(fps, 4, 4, 2, vram);
127 // Moving this on the lower left side of screen for now, since the lack of double buffering generates flickering for this atm
128 drawDecimal(fps, 4, fb_height - 12, 2, vram);