feature (kernel): Implemented graphics_buffer text scrolling

This commit is contained in:
antifallobst 2023-02-24 23:44:34 +01:00
parent 0be2a54467
commit 2624162ad8
3 changed files with 32 additions and 11 deletions

View File

@ -58,6 +58,7 @@ graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_
void graphics_buffer_show (graphics_buffer_T* graphics_buffer); void graphics_buffer_show (graphics_buffer_T* graphics_buffer);
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer); void graphics_buffer_hide (graphics_buffer_T* graphics_buffer);
void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer); void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer);
void graphics_buffer_shift_up (graphics_buffer_T* graphics_buffer, uint16_t shift);
void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color); void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color);
color_argb_T graphics_buffer_get_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y); color_argb_T graphics_buffer_get_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y);
void graphics_buffer_draw_char (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, char chr); void graphics_buffer_draw_char (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, char chr);

View File

@ -66,6 +66,16 @@ void graphics_buffer_destruct(graphics_buffer_T* graphics_buffer) {
memory_free(graphics_buffer); memory_free(graphics_buffer);
} }
void graphics_buffer_shift_up(graphics_buffer_T* graphics_buffer, uint16_t shift) {
memory_copy(&graphics_buffer->buffer[graphics_buffer->width * shift],
graphics_buffer->buffer,
graphics_buffer->width * (graphics_buffer->height - shift) * sizeof(color_argb_T));
memory_set(&graphics_buffer->buffer[graphics_buffer->width * (graphics_buffer->height - shift)],
0,
graphics_buffer->width * shift * sizeof(color_argb_T));
}
void graphics_buffer_set_pixel(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color) { void graphics_buffer_set_pixel(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color) {
graphics_buffer->buffer[y * graphics_buffer->width + x] = color; graphics_buffer->buffer[y * graphics_buffer->width + x] = color;
} }
@ -113,6 +123,10 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3
pos.x = 0; pos.x = 0;
pos.y += g_renderer.font.height; pos.y += g_renderer.font.height;
} }
if (pos.y + g_renderer.font.height >= graphics_buffer->height) {
pos.y -= g_renderer.font.height;
graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height);
}
graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]); graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]);
pos.x += g_renderer.font.width; pos.x += g_renderer.font.width;
break; break;
@ -180,6 +194,8 @@ void graphics_renderer_update_graphics_buffer(graphics_buffer_T* graphics_buffer
} }
void graphics_renderer_update() { void graphics_renderer_update() {
memory_set(g_renderer.back_buffer, 0, g_renderer.buffer_size);
graphics_buffer_T* graphics_buffer = g_renderer.graphics_buffer_layers[GRAPHICS_BUFFER_STANDARD]; graphics_buffer_T* graphics_buffer = g_renderer.graphics_buffer_layers[GRAPHICS_BUFFER_STANDARD];
while (graphics_buffer != NULL) { while (graphics_buffer != NULL) {
graphics_renderer_update_graphics_buffer(graphics_buffer); graphics_renderer_update_graphics_buffer(graphics_buffer);

View File

@ -81,19 +81,23 @@ void kmain(boot_info_T boot_info) {
limine_terminal_print(&boot_info, "Kernel initialized\n"); limine_terminal_print(&boot_info, "Kernel initialized\n");
log(LOG_INFO, "!=====[ Kernel Initialized ]=====!\n"); log(LOG_INFO, "!=====[ Kernel Initialized ]=====!\n");
vfs_node_T* node_temp = vfs_node_create(g_vfs_root_node, "temp", VFS_NODE_DIRECTORY); for (int i = 0; i < 150; i++) {
vfs_node_T* node_system = vfs_node_create(g_vfs_root_node, "system", VFS_NODE_DIRECTORY); log(LOG_DEBUG, "test log %d", i);
vfs_node_T* node_config = vfs_node_create(node_system, "config", VFS_NODE_DIRECTORY);
vfs_node_T* node_test = vfs_node_create(node_config, "test.conf", VFS_NODE_FILE);
vfs_node_T* result = vfs_resolve_path("/system/config/test.conf");
if (result == node_test) {
log(LOG_DEBUG, "resolve test passed");
} else {
log(LOG_DEBUG, "resolve test failed 0x%x != 0x%x", result, node_test);
} }
vfs_node_dump_info(g_vfs_root_node, 0); // vfs_node_T* node_temp = vfs_node_create(g_vfs_root_node, "temp", VFS_NODE_DIRECTORY);
// vfs_node_T* node_system = vfs_node_create(g_vfs_root_node, "system", VFS_NODE_DIRECTORY);
// vfs_node_T* node_config = vfs_node_create(node_system, "config", VFS_NODE_DIRECTORY);
// vfs_node_T* node_test = vfs_node_create(node_config, "test.conf", VFS_NODE_FILE);
//
// vfs_node_T* result = vfs_resolve_path("/system/config/test.conf");
// if (result == node_test) {
// log(LOG_DEBUG, "resolve test passed");
// } else {
// log(LOG_DEBUG, "resolve test failed 0x%x != 0x%x", result, node_test);
// }
// vfs_node_dump_info(g_vfs_root_node, 0);
CORE_HALT_FOREVER CORE_HALT_FOREVER
} }