Broken term scrolling

This commit is contained in:
2026-01-10 14:43:51 +01:00
parent b469952d91
commit 091f94f89e
6 changed files with 26 additions and 23 deletions

View File

@@ -185,13 +185,14 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
break; break;
case 32: case 32:
//DEBUG("Tick!"); //DEBUG("Timer Interrupt");
ticks++; ticks++;
// Send an EOI so that we can continue having interrupts // Send an EOI so that we can continue having interrupts
outb(0x20, 0x20); outb(0x20, 0x20);
break; break;
case 33: case 33:
DEBUG("Keyboard Interrupt");
keyboard_handler(); keyboard_handler();
break; break;

View File

@@ -201,12 +201,11 @@ void keyboard_handler()
if (c) if (c)
{ {
putchar(c); // Should probably have a keyboard buffer here... instead of this
//putchar(c);
} }
} }
} }
skputs("key pressed!\n");
} }
// End of Interrupt (to master PIC) // End of Interrupt (to master PIC)
@@ -233,5 +232,11 @@ void keyboard_init(unsigned char layout)
skputs("Unsupported layout."); skputs("Unsupported layout.");
return; return;
} }
// Unmask IRQ1
uint8_t mask = inb(0x21);
mask &= ~(1 << 1);
outb(0x21, mask);
DEBUG("PS/2 Keyboard initialized"); DEBUG("PS/2 Keyboard initialized");
} }

View File

@@ -23,6 +23,8 @@ uint8_t* glyphs = _binary_zap_light16_psf_start + sizeof(PSF1_Header);
#define FONT_WIDTH 8 #define FONT_WIDTH 8
#define FONT_HEIGHT font->characterSize #define FONT_HEIGHT font->characterSize
// Character cursor // Character cursor
typedef struct typedef struct
{ {
@@ -102,7 +104,7 @@ static void erase_char(size_t px, size_t py)
for (size_t y=0; y<FONT_HEIGHT; y++) for (size_t y=0; y<FONT_HEIGHT; y++)
{ {
for (size_t x=0; x<FONT_HEIGHT; x++) for (size_t x=0; x<FONT_WIDTH; x++)
{ {
// Black // Black
putpixel(px+x, py+y, 0); putpixel(px+x, py+y, 0);
@@ -112,21 +114,15 @@ static void erase_char(size_t px, size_t py)
void term_scroll() void term_scroll()
{ {
const size_t row_height = FONT_HEIGHT; // Erase first text line
const size_t row_bytes = framebuffer->pitch; memset(fb, 255, FONT_HEIGHT*framebuffer->pitch);
const size_t screen_rows = framebuffer->height;
// Move framebuffer up by one text row // Move whole framebuffer up by one text line
//memmove(fb, fb + row_height * row_bytes, (screen_rows - row_height) * row_bytes); memmove(fb, fb+(FONT_HEIGHT*framebuffer->pitch), (framebuffer->height-FONT_HEIGHT)*framebuffer->pitch);
for (size_t i = 0; i < (screen_rows - row_height) * row_bytes; i++) // Clear last text line
{ size_t clear_start = (framebuffer->height - FONT_HEIGHT) * framebuffer->pitch;
fb[i] = fb[i + row_height * row_bytes]; memset(fb + clear_start, 255, FONT_HEIGHT * framebuffer->pitch);
}
// Clear last text row
size_t clear_start = (screen_rows - row_height) * row_bytes;
memset(fb + clear_start, 0, row_height * row_bytes);
// Shift line lengths by 1 (for backspace handling) // Shift line lengths by 1 (for backspace handling)
size_t max_lines = term_max_lines(); size_t max_lines = term_max_lines();
@@ -134,11 +130,9 @@ void term_scroll()
{ {
lines_length[i - 1] = lines_length[i]; lines_length[i - 1] = lines_length[i];
} }
lines_length[max_lines - 1] = 0; lines_length[max_lines - 1] = 0;
} }
void putchar(char c) void putchar(char c)
{ {
const size_t max_cols = term_max_cols(); const size_t max_cols = term_max_cols();

View File

@@ -22,4 +22,7 @@ typedef struct
uint8_t characterSize; // height uint8_t characterSize; // height
} PSF1_Header; } PSF1_Header;
// debug
void term_scroll();
#endif #endif

View File

@@ -118,11 +118,11 @@ void kmain()
term_init(); term_init();
kputs(splash); kputs(splash);
for (int i=0; i<50; i++) for (int i=0; i<10; i++)
{ {
printf("testing, attention please %d\n", i); printf("testing, attention please %d\n", i);
timer_wait(1000);
} }
term_scroll();
hcf(); hcf();
} }

View File

@@ -44,7 +44,7 @@ void pic_enable()
// Enabling IRQ0 (unmasking it) but not the others // Enabling IRQ0 (unmasking it) but not the others
uint8_t mask = inb(0x21); uint8_t mask = inb(0x21);
mask &= ~(1 << 0); // Set IRQ0 (timer, clear bit 0) mask &= ~(1 << 0); // Set IRQ0 (timer, clear bit 0)
mask &= ~(1 << 1); // Set IRQ1 (PS/2 Keyboard, clear bit 1) //mask &= ~(1 << 1); // Set IRQ1 (PS/2 Keyboard, clear bit 1)
outb(0x21, mask); outb(0x21, mask);
} }