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.
13 1110 0010 1110 1110 1010 1110 1110 1110 1110 1110
14 1010 0010 0010 0010 1010 1000 1000 0010 1010 1010
15 1010 0010 1110 0110 1110 1110 1110 0010 1110 1110
16 1010 0010 1000 0010 0010 0010 1010 0010 1010 0010
17 1110 0010 1110 1110 0010 1110 1110 0010 1110 1110
20 static const unsigned char miniDecimalData[] = { 0xE2, 0xEE, 0xAE, 0xEE, 0xEE,
21 0xA2, 0x22, 0xA8, 0x82, 0xAA,
22 0xA2, 0xE6, 0xEE, 0xE2, 0xEE,
23 0xA2, 0x82, 0x22, 0xA2, 0xA2,
24 0xE2, 0xEE, 0x2E, 0xE2, 0xEE };
26 static unsigned short miniDecimalFonts[FPS_FONT_NUM_PIXELS];
28 static unsigned long startingFpsTime = 0;
29 static int fpsFontsInit = 0;
30 static int nFrames = 0;
34 if (fpsFontsInit == 0)
36 unsigned char miniDecimalPixels[FPS_FONT_NUM_PIXELS];
40 for (i = 0; i < FPS_FONT_NUM_PIXELS / 8; i++)
42 unsigned char d = miniDecimalData[i];
43 for (j = 0; j < 8; j++)
45 unsigned char c = (d & 0x80) >> 7;
46 miniDecimalPixels[k++] = c;
52 for (n = 0; n < FPS_FONTS_NUM; n++)
54 for (y = 0; y < FPS_FONT_HEIGHT; y++)
56 for (x = 0; x < FPS_FONT_WIDTH; x++)
58 miniDecimalFonts[i++] = miniDecimalPixels[n * FPS_FONT_WIDTH + x + y * FPS_FONT_WIDTH * FPS_FONTS_NUM] * 0xFFFF;
67 static void drawFont(unsigned char decimal, int posX, int posY, unsigned char zoom, unsigned short *vram)
72 unsigned short *fontData = (unsigned short*)&miniDecimalFonts[decimal * FPS_FONT_WIDTH * FPS_FONT_HEIGHT];
74 vram += posY * FB_WIDTH + posX;
76 if (zoom < 1) zoom = 1;
77 if (zoom > 4) zoom = 4;
79 for (y = 0; y<FPS_FONT_HEIGHT; y++)
81 for (x = 0; x<FPS_FONT_WIDTH; x++)
87 for (j=0; j<zoom; j++)
89 for (k=0; k<zoom; k++)
91 *(vram + j * FB_WIDTH + k) ^= c;
97 vram += (-FPS_FONT_WIDTH * zoom + FB_WIDTH * zoom);
101 static void drawDecimal(unsigned int number, int posX, int posY, unsigned char zoom, unsigned short *vram)
106 sprintf(buffer, "%d", number);
108 while(i < 8 && buffer[i] != 0)
110 drawFont(buffer[i] - 48, posX + i * zoom * FPS_FONT_WIDTH, posY, zoom, vram);
115 void drawFps(unsigned short *vram)
117 unsigned long dt = time_msec - startingFpsTime;
123 fps = (nFrames * 1000) / dt;
124 startingFpsTime = time_msec;
127 /*drawDecimal(fps, 4, 4, 2, vram);*/
128 /* Moving this on the lower left side of screen for now, since the lack of double buffering generates flickering for this atm */
129 drawDecimal(fps, 4, FB_HEIGHT - 12, 2, vram);