Skip to content

Commit

Permalink
Add PIN_LOGO variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed Aug 5, 2024
1 parent 722e278 commit dbbd6b3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build/Common.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEF_FLAGS := -D USE_FRAMEBUFFER=$(USE_FRAMEBUFFER) -D SMALL_PAGES=$(SMALL_PAGES)
DEF_FLAGS := -D USE_FRAMEBUFFER=$(USE_FRAMEBUFFER) -D SMALL_PAGES=$(SMALL_PAGES) -D PIN_LOGO=$(PIN_LOGO)

CFLAGS := -std=gnu99 \
-ffreestanding \
Expand Down
5 changes: 4 additions & 1 deletion build/Config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# Kernel Configuration

USE_FRAMEBUFFER ?= 1
SMALL_PAGES ?= 0
SMALL_PAGES ?= 1

# PIN_LOGO set to 0 if we want the logo to be scrolled.
PIN_LOGO ?= 1

# Build Configuration

Expand Down
1 change: 1 addition & 0 deletions docs/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ They can change at any moment, or can be removed in the future

* `USE_FRAMEBUFFER` if set to 1 it use the framebuffer video mode, if set to 0 it use the legacy VGA driver.
* `SMALL_PAGES` if set to 1 the virtual memory will use 4k pages if set to 0 it will use 2mb pages
* `PIN_LOGO` if set to 1 the dreamos logo will stay on the top right corner when the frambuffer is scrolling, otherwise will scroll up with the rest of the screen.

They are experimental temporary features, there are chances that they can be removed in the future.

Expand Down
2 changes: 1 addition & 1 deletion src/include/kernel/framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ void get_framebuffer_mode(uint32_t* pixels_w, uint32_t* pixels_h, uint32_t* char
void draw_logo(uint32_t start_x, uint32_t start_y);

void _fb_scrollLine(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin);
void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin);
void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin, bool clear_last_line);

#endif
22 changes: 17 additions & 5 deletions src/kernel/framebuffer/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ uint32_t number_of_lines;

_fb_window_t framebuffer_main_window;
_fb_window_t framebuffer_logo_area;
_fb_window_t *logo_area_ptr;

void map_framebuffer(struct framebuffer_info fbdata) {
uint32_t fb_entries = fbdata.memory_size / PAGE_SIZE_IN_BYTES;
Expand Down Expand Up @@ -116,6 +117,7 @@ void set_fb_data(struct multiboot_tag_framebuffer *fbtag){
framebuffer_main_window.y_orig = 0;
framebuffer_main_window.width = framebuffer_data.width;
framebuffer_main_window.height = framebuffer_data.height;
logo_area_ptr = NULL;

#endif
}
Expand Down Expand Up @@ -163,7 +165,8 @@ void _fb_printStr( const char *string, uint32_t fg, uint32_t bg ) {
cur_fb_line++;
if ( cur_fb_line >= framebuffer_data.number_of_lines ) {
//pretty_log(Verbose, "Exceeding number of lines, calling _fb_scrollLine");
_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
//_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, logo_area_ptr, true);
cur_fb_line--;
}
}
Expand All @@ -173,7 +176,8 @@ void _fb_printStrAndNumber(const char *string, uint64_t number, uint32_t fg, uin
cur_fb_line++;
if ( cur_fb_line >= framebuffer_data.number_of_lines ) {
//pretty_log(Verbose, "Exceeding number of lines, calling _fb_scrollLine");
_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
//_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, logo_area_ptr, true);
cur_fb_line--;
}
}
Expand All @@ -186,7 +190,8 @@ void _fb_printStrAt( const char *string, size_t cx, size_t cy, uint32_t fg, uint
cur_fb_line = cy;
if ( cur_fb_line+1 >= framebuffer_data.number_of_lines ) {
//pretty_log(Verbose, "Exceeding number of lines, calling _fb_scrollLine");
_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
//_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, logo_area_ptr, true);
} else {
cy++;
cur_fb_line = cy;
Expand Down Expand Up @@ -260,6 +265,11 @@ void draw_logo(uint32_t start_x, uint32_t start_y) {
framebuffer_logo_area.y_orig = start_y;
framebuffer_logo_area.width = width;
framebuffer_logo_area.height = height;
#if PIN_LOGO == 1
logo_area_ptr = &framebuffer_logo_area;
#else
logo_area_ptr = NULL;
#endif
char *logo_data = header_data;
char *data = header_data;
unsigned char pixel[4];
Expand All @@ -276,7 +286,7 @@ void draw_logo(uint32_t start_x, uint32_t start_y) {
}
}

void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin) {
void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin, bool clear_last_line) {
_fb_window_t rectangles[4];
uint32_t *framebuffer = (uint32_t *) framebuffer_data.address;
uint8_t n_rects = _fb_get_rectangles(rectangles, &framebuffer_main_window, area_to_pin);
Expand All @@ -298,7 +308,9 @@ void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t n
while ( cur_y < (rectangles[i].y_orig + rectangles[i].height - line_height)) {
while (cur_x < (rectangles[i].x_orig + rectangles[i].width)) {
_fb_put_pixel(cur_x, cur_y, _fb_get_pixel(cur_x, cur_y + line_height));
_fb_put_pixel(cur_x, cur_y + line_height, 0x000000);
if (clear_last_line) {
_fb_put_pixel(cur_x, cur_y + line_height, 0x000000);
}
cur_x++;
}
cur_y++;
Expand Down
18 changes: 5 additions & 13 deletions src/kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,12 @@ void kernel_start(unsigned long addr, unsigned long magic){

draw_logo(framebuffer_data.width - width, 0);
_fb_printStr("Thanks\n\tfor\n using it\n", 0xFFFFFF, 0x3333ff);
/*_fb_window_t squares[4];
uint8_t n_rectangles = _fb_get_rectangles(squares, &framebuffer_main_window, &framebuffer_logo_area);
for (int i = 0; i < n_rectangles; i++) {
pretty_logf(Verbose, "Square: %d, x_orig: %d, y_orig: %d, widht: %d, height: %d", i, squares[i].x_orig, squares[i].y_orig, squares[i].width, squares[i].height);
}
_fb_window_t rect_to_draw = {600, 500, 100, 120};
_fb_window_t main_area = {400, 300, 400, 400};
size_t n_rects = _fb_get_rectangles(squares, &main_area, &rect_to_draw);
pretty_logf(Verbose, "Checking size of rectangles returned: %d", n_rects);
uint32_t colours[4] = {0x83A06A, 0x465259, 0x8FD8F9, 0xF7E65A};
for (size_t i = 0; i < n_rects; i++) {
_fb_draw_rectangle(main_area, squares[i], colours[i]);
_fb_printStrAt("Test String", 0, 49, 0xff33aa, 0x000000);
/*pretty_logf(Verbose, "Framebuffer addr: 0x%x", framebuffer_data.address);
for (int i = 0; i < 60; i++) {
_fb_printStrAndNumber("Counting up to: ", i, 0xFF33AA+i, 0x000000);
}*/
_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area);
//_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area, false);
//_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, NULL);
#endif
_syscalls_init();
Expand Down

0 comments on commit dbbd6b3

Please sign in to comment.