blob: ca6ddb62e94ff9670b00467bbd02cadbf29db281 (
plain) (
blame)
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
|
#include <framebuffer.h>
#include <stdint.h>
#include <stddef.h>
uint32_t* fb_addr;
uint64_t fb_width;
uint64_t fb_height;
void fb_init(uint32_t* addr, uint64_t width, uint64_t height) {
fb_addr = addr;
fb_width = width;
fb_height = height;
fb_clear();
}
void fb_clear() {
for (size_t y = 0; y < fb_height; y++) {
for (size_t x = 0; x < fb_width; x++) {
const size_t i = y * fb_width + x;
fb_addr[i] = 0x000000;
}
}
}
void draw_pixel(const uint64_t x, const uint64_t y, const uint32_t color) {
const size_t pos = y * fb_width + x;
fb_addr[pos] = color;
}
void draw_bitmap(const uint32_t* bitmap, const uint64_t x_pos, const uint64_t y_pos, const uint64_t width, const uint64_t height) {
for (size_t y = 0; y < height; y++) {
for (size_t x = 0; x < width; x++) {
const size_t i = y * width + x;
draw_pixel(x_pos + x, y_pos + y, bitmap[i]);
}
}
}
|