SayoriOS 0.3.3

gfxbench.c
1 //
2 // Created by ndraey on 08.11.23.
3 //
4
5 #include <common.h>
6 #include "drv/input/keymap.h"
7 #include "drv/input/keyboard.h"
8 #include "io/screen.h"
9 #include "sys/timer.h"
10 #include "lib/sprintf.h"
11
12 uint32_t gfxbench(uint32_t argc, char* args[]) {
13 size_t frames = 0;
14 size_t fps = 0;
15 size_t last_measurement = timestamp();
16
17 size_t scrw = getScreenWidth();
18 size_t scrh = getScreenHeight();
19 size_t scrbpp = getDisplayBpp();
20
21 char* string = 0;
22
23 keyboardctl(KEYBOARD_ECHO, false);
24
25 while(1) {
26 if(getCharRaw() == KEY_ESC)
27 break;
28
29 if(timestamp() - last_measurement >= 1000) {
30 last_measurement = timestamp();
31 fps = frames;
32 frames = 0;
33 }
34
35 drawRect(0, 0, scrw, scrh, 0x999999);
36
37 asprintf(&string, "[%d x %d @ %d bits] %d FPS", scrw, scrh, scrbpp, fps);
38
39 draw_vga_str(string, strlen(string), 0, 0, 0x000000);
40
41 if(string)
42 kfree(string);
43
44 punch();
45
46 frames++;
47 }
48
49 keyboardctl(KEYBOARD_ECHO, true);
50
51 return 0;
52 }
common.h
Основные определения ядра
strlen
size_t strlen(const char *str)
Возращает длину строки
Definition: string.c:88
drawRect
void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color)
Рисуем залитый прямоугольник
Definition: pixel.c:25