feature: terminal scroll works again (with a bg image, without the bg image it's a wip)
This commit is contained in:
parent
3b0b090430
commit
dda9c8a1ef
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
int isprint(int c)
|
||||
{
|
||||
return (32 <= c && c < 127);
|
||||
return (c >= 32 && c < 127);
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
#include "vbe.h"
|
||||
#include "drivers.h"
|
||||
#include "icon.h"
|
||||
|
||||
struct vbe_interface display;
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "drivers.h"
|
||||
#include "gdt.h"
|
||||
#include "icon.h"
|
||||
#include "icons/image.h"
|
||||
#include "idt.h"
|
||||
#include "kprintf.h"
|
||||
#include "memory.h"
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "font.h"
|
||||
#include "fonts/eating_pasta_regular_13.h"
|
||||
#include "fonts/minecraft_medium_13.h"
|
||||
#include "icons/image.h"
|
||||
#include "kprintf.h"
|
||||
#include "shell.h"
|
||||
#include "string.h"
|
||||
@ -75,16 +76,21 @@ uint8_t terminal_get_char(int x, int y)
|
||||
void terminal_putentryat(struct font node, uint32_t fg_color, uint32_t bg_color,
|
||||
size_t x, size_t y)
|
||||
{
|
||||
if (node.width == 1 && node.height == 1) {
|
||||
return;
|
||||
}
|
||||
char *glyph = node.bitmap;
|
||||
for (size_t cy = 0; cy < node.height; cy++) {
|
||||
for (size_t cx = 0; cx < node.width; cx++) {
|
||||
put_pixel((glyph[cy * node.width + cx] == '#')
|
||||
? fg_color
|
||||
: bg_color,
|
||||
x + cx, y + cy);
|
||||
/* put_pixel((fg_color, x + cx, y + cy); */
|
||||
if (glyph[cy * node.width + cx] == '#')
|
||||
put_pixel(fg_color, x + cx, y + cy);
|
||||
/* put_pixel((glyph[cy * node.width +
|
||||
* cx] == '#') ? fg_color */
|
||||
/* : bg_color, */
|
||||
/* x + cx, y + cy); */
|
||||
/* else if (bg_color) */
|
||||
/* put_pixel(bg_color, x + cx, y + cy); */
|
||||
/* put_pixel(bg_color, x + cx, y + cy);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,21 +103,23 @@ static struct font get_font_node(int c)
|
||||
static void terminal_scroll(void)
|
||||
{
|
||||
screen->row--;
|
||||
draw_icon(0, 0, &image_icon);
|
||||
for (size_t i = 0; i < VGA_WIDTH * (VGA_HEIGHT - 1); i++) {
|
||||
const uint32_t x = (i % VGA_WIDTH) * FONT_SIZE;
|
||||
const uint32_t y = (i / VGA_WIDTH) * FONT_SIZE;
|
||||
screen->buffer[i] = screen->buffer[i + VGA_WIDTH];
|
||||
terminal_putentryat(get_font_node(screen->buffer[i]),
|
||||
screen->fg_color, screen->bg_color, x, y);
|
||||
}
|
||||
/* for (size_t i = 0; i < VGA_WIDTH; i++) */
|
||||
/* terminal_putentryat(get_font_node(' '), 0, 0, i * FONT_SIZE, */
|
||||
/* VGA_HEIGHT - 1); */
|
||||
/* (VGA_HEIGHT - 1) * FONT_SIZE); */
|
||||
}
|
||||
|
||||
static void terminal_new_line(void)
|
||||
{
|
||||
screen->column = 0;
|
||||
if (++screen->row == VGA_HEIGHT)
|
||||
if (++screen->row == VGA_HEIGHT - 1)
|
||||
terminal_scroll();
|
||||
}
|
||||
|
||||
@ -121,20 +129,23 @@ void terminal_change_default_color(uint32_t color)
|
||||
/* terminal_set_color(color); */
|
||||
/* for (size_t y = 0; y < VGA_HEIGHT; y++) { */
|
||||
/* for (size_t x = 0; x < VGA_WIDTH; x++) { */
|
||||
/* const size_t index = y * VGA_WIDTH + x; */
|
||||
/* const size_t index = y * VGA_WIDTH + x;
|
||||
*/
|
||||
/* uint8_t entry_color =
|
||||
* get_entry_color(TERM_BUF[index]);
|
||||
*/
|
||||
/* TERM_BUF[index] = vga_entry( */
|
||||
/* TERM_BUF[index], */
|
||||
/* entry_color == screen->default_color ? color
|
||||
/* entry_color == screen->default_color
|
||||
* ? color
|
||||
*/
|
||||
/* :
|
||||
* entry_color);
|
||||
*/
|
||||
/* } */
|
||||
/* } */
|
||||
/* memcpy(screen->buffer, TERM_BUF, sizeof(screen->buffer)); */
|
||||
/* memcpy(screen->buffer, TERM_BUF,
|
||||
* sizeof(screen->buffer)); */
|
||||
/* screen->default_color = color; */
|
||||
/* screen->color = color; */
|
||||
}
|
||||
@ -150,12 +161,15 @@ void terminal_clear(void)
|
||||
// TODO
|
||||
/* for (size_t y = 0; y < VGA_HEIGHT; y++) { */
|
||||
/* for (size_t x = 0; x < VGA_WIDTH; x++) { */
|
||||
/* const size_t index = y * VGA_WIDTH + x; */
|
||||
/* TERM_BUF[index] = vga_entry(' ', screen->color);
|
||||
/* const size_t index = y * VGA_WIDTH + x;
|
||||
*/
|
||||
/* TERM_BUF[index] = vga_entry(' ',
|
||||
* screen->color);
|
||||
*/
|
||||
/* } */
|
||||
/* } */
|
||||
/* memcpy(screen->buffer, TERM_BUF, sizeof(screen->buffer)); */
|
||||
/* memcpy(screen->buffer, TERM_BUF,
|
||||
* sizeof(screen->buffer)); */
|
||||
/* screen->column = 0; */
|
||||
/* screen->row = 0; */
|
||||
}
|
||||
@ -168,12 +182,19 @@ int terminal_putchar(char c)
|
||||
terminal_new_line();
|
||||
if (!isprint(c))
|
||||
return 1;
|
||||
/* if (c == ' ') { */
|
||||
/* for (size_t cy = 0; cy < 13; cy++) */
|
||||
/* for (size_t cx = 0; cx < 13; cx++) */
|
||||
/* put_pixel(0, screen->column + cx, */
|
||||
/* screen->row + cy); */
|
||||
/* } else { */
|
||||
screen->buffer[screen->column + screen->row * VGA_WIDTH] = c;
|
||||
terminal_putentryat(get_font_node(c), screen->fg_color,
|
||||
screen->bg_color, screen->column * FONT_SIZE,
|
||||
screen->row * FONT_SIZE);
|
||||
if (++screen->column == VGA_WIDTH)
|
||||
terminal_new_line();
|
||||
/* } */
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -194,7 +215,8 @@ int terminal_writestring(const char *data)
|
||||
|
||||
void update_cursor(void)
|
||||
{
|
||||
/* uint16_t pos = screen->row * VGA_WIDTH + screen->column; */
|
||||
/* uint16_t pos = screen->row * VGA_WIDTH +
|
||||
* screen->column; */
|
||||
|
||||
/* outb(0x3D4, 0x0F); */
|
||||
/* outb(0x3D5, pos & 0xFF); */
|
||||
|
37
tools/icon_maker.py
Normal file
37
tools/icon_maker.py
Normal file
@ -0,0 +1,37 @@
|
||||
from PIL import Image
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
if (len(sys.argv) < 2):
|
||||
print("Error: usage python icon_maker.py {img}")
|
||||
|
||||
image = Image.open(sys.argv[1])
|
||||
|
||||
width, height = image.size
|
||||
pixels = list(image.getdata())
|
||||
pixels = [r << 16 | g << 8 | b for r, g, b in pixels]
|
||||
|
||||
string = str(pixels).replace("(", "{").replace(")", "}").replace("[", "{").replace("]", "}")
|
||||
|
||||
filename: str = os.path.basename(sys.argv[1]).split(".")[0]
|
||||
|
||||
string = f"""\
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "icon.h"
|
||||
|
||||
uint32_t {filename}_color_map[{width} * {height}] = {string};
|
||||
|
||||
struct icon {filename}_icon = {{
|
||||
.height = {height},
|
||||
.width = {width},
|
||||
.pixels = {filename}_color_map
|
||||
}};
|
||||
|
||||
"""
|
||||
|
||||
with open(f"./headers/icons/{filename}.h", "w") as f:
|
||||
f.write(string)
|
Loading…
Reference in New Issue
Block a user