mirror of
https://github.com/usatiuk/ficus.git
synced 2025-10-29 00:27:52 +01:00
Basic framebuffer text output
This commit is contained in:
@@ -15,5 +15,5 @@ int LimineFramebuffer::get(size_t x, size_t y) {
|
|||||||
return *coord_to_ptr(x, y);
|
return *coord_to_ptr(x, y);
|
||||||
}
|
}
|
||||||
uint32_t *LimineFramebuffer::coord_to_ptr(size_t x, size_t y) {
|
uint32_t *LimineFramebuffer::coord_to_ptr(size_t x, size_t y) {
|
||||||
return &((uint32_t *) _backing->address)[x * (_backing->pitch / 4) + y];
|
return &((uint32_t *) _backing->address)[y * (_backing->pitch / 4) + x];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "task.hpp"
|
#include "task.hpp"
|
||||||
#include "timer.hpp"
|
#include "timer.hpp"
|
||||||
|
|
||||||
|
#include <FbTty.hpp>
|
||||||
#include <LimineFramebuffer.hpp>
|
#include <LimineFramebuffer.hpp>
|
||||||
|
|
||||||
void templates_tester() {
|
void templates_tester() {
|
||||||
@@ -46,6 +47,8 @@ void vfs_tester() {
|
|||||||
|
|
||||||
void ktask_main() {
|
void ktask_main() {
|
||||||
GlobalTtyManager.add_tty(new SerialTty());
|
GlobalTtyManager.add_tty(new SerialTty());
|
||||||
|
for (int i = 0; i < framebuffer_count; i++)
|
||||||
|
GlobalTtyManager.add_tty(new FbTty(new LimineFramebuffer(&framebuffers[i])));
|
||||||
|
|
||||||
(new Task(Task::TaskMode::TASKMODE_KERN, templates_tester, "templates_tester"))->start();
|
(new Task(Task::TaskMode::TASKMODE_KERN, templates_tester, "templates_tester"))->start();
|
||||||
(new Task(Task::TaskMode::TASKMODE_KERN, templates_tester, "templates_tester2"))->start();
|
(new Task(Task::TaskMode::TASKMODE_KERN, templates_tester, "templates_tester2"))->start();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ target_sources(kernel.elf PRIVATE
|
|||||||
string.c
|
string.c
|
||||||
TestTemplates.cpp
|
TestTemplates.cpp
|
||||||
Framebuffer.cpp
|
Framebuffer.cpp
|
||||||
|
FbTty.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(templates)
|
add_subdirectory(templates)
|
||||||
|
|||||||
44
src/kernel/FbTty.cpp
Normal file
44
src/kernel/FbTty.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// Created by Stepan Usatiuk on 26.04.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "FbTty.hpp"
|
||||||
|
#include "Fonts.hpp"
|
||||||
|
|
||||||
|
#include <Framebuffer.hpp>
|
||||||
|
|
||||||
|
FbTty::FbTty(Framebuffer *fb) : _fb(fb) {
|
||||||
|
_max_col = _fb->dimensions().x / 8;
|
||||||
|
_max_row = _fb->dimensions().y / 16;
|
||||||
|
}
|
||||||
|
void FbTty::putchar(char c) {
|
||||||
|
if (c == '\n') {
|
||||||
|
next_row();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = 0; x < 8; x++) {
|
||||||
|
for (int y = 0; y < 16; y++) {
|
||||||
|
uint32_t color = (fonts_Terminess_Powerline[c][y] & (1 << (8 - x))) ? 0xFFFFFF : 0;
|
||||||
|
_fb->set(_cur_col * 8 + x, _cur_row * 16 + y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next_col();
|
||||||
|
}
|
||||||
|
void FbTty::putstr(const char *str) {
|
||||||
|
while (*str != 0) {
|
||||||
|
putchar(*str);
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char FbTty::readchar() {
|
||||||
|
}
|
||||||
|
void FbTty::next_col() {
|
||||||
|
_cur_col++;
|
||||||
|
_cur_col = _cur_col % _max_col;
|
||||||
|
if (_cur_col == 0) next_row();
|
||||||
|
}
|
||||||
|
void FbTty::next_row() {
|
||||||
|
_cur_col = 0;
|
||||||
|
_cur_row++;
|
||||||
|
_cur_row = _cur_row % _max_row;
|
||||||
|
}
|
||||||
34
src/kernel/FbTty.hpp
Normal file
34
src/kernel/FbTty.hpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// Created by Stepan Usatiuk on 26.04.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef FBTTY_HPP
|
||||||
|
#define FBTTY_HPP
|
||||||
|
#include <Tty.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
class Framebuffer;
|
||||||
|
class FbTty : public Tty {
|
||||||
|
public:
|
||||||
|
FbTty(Framebuffer *fb);
|
||||||
|
virtual ~FbTty() = default;
|
||||||
|
|
||||||
|
void putchar(char c) override;
|
||||||
|
void putstr(const char *str) override;
|
||||||
|
char readchar() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Framebuffer *_fb;
|
||||||
|
|
||||||
|
int _cur_col = 0;
|
||||||
|
int _cur_row = 0;
|
||||||
|
|
||||||
|
int _max_row = 0;
|
||||||
|
int _max_col = 0;
|
||||||
|
|
||||||
|
void next_col();
|
||||||
|
void next_row();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //FBTTY_HPP
|
||||||
4878
src/kernel/Fonts.hpp
Normal file
4878
src/kernel/Fonts.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user