[ansiterm] Fix a bunch of crap with the ANSI term and output in general.
This commit is contained in:
parent
ad8175e0f5
commit
f06f65d941
|
@ -27,11 +27,7 @@ parse_args(char * arg) {
|
|||
if (!strcmp(argv[i],"vid=qemu")) {
|
||||
/* QEMU Video Mode, we are free to set things for 1024x768 */
|
||||
graphics_install_bochs();
|
||||
bochs_draw_logo("/bs.bmp");
|
||||
char * welcome = "Welcome to \200\201\202OS!\n";
|
||||
for (uint16_t i = 0; i < strlen(welcome); ++i) {
|
||||
bochs_write(welcome[i]);
|
||||
}
|
||||
ansi_init(&bochs_write, 128, 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ putch(
|
|||
if (keyboard_buffer_handler) {
|
||||
keyboard_buffer_handler(c);
|
||||
} else {
|
||||
writech(c);
|
||||
ansi_put(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,14 @@ int kgets_want = 0;
|
|||
int kgets_newline = 0;
|
||||
int kgets_cancel = 0;
|
||||
|
||||
static void
|
||||
kwrite(
|
||||
char ch
|
||||
) {
|
||||
ansi_put(ch);
|
||||
serial_send(ch);
|
||||
}
|
||||
|
||||
void
|
||||
kgets_handler(
|
||||
char ch
|
||||
|
@ -127,23 +135,23 @@ kgets_handler(
|
|||
if (ch == 0x08) {
|
||||
/* Backspace */
|
||||
if (kgets_collected != 0) {
|
||||
writech(0x08);
|
||||
writech(' ');
|
||||
writech(0x08);
|
||||
kwrite(0x08);
|
||||
kwrite(' ');
|
||||
kwrite(0x08);
|
||||
kgets_buffer[kgets_collected] = '\0';
|
||||
--kgets_collected;
|
||||
}
|
||||
return;
|
||||
} else if (ch == '\n') {
|
||||
writech('\n');
|
||||
kwrite('\n');
|
||||
kgets_newline = 1;
|
||||
return;
|
||||
} else if (ch < 0x20) {
|
||||
writech('^');
|
||||
writech(ch + 0x40);
|
||||
kwrite('^');
|
||||
kwrite(ch + 0x40);
|
||||
return;
|
||||
} else {
|
||||
writech(ch);
|
||||
kwrite(ch);
|
||||
}
|
||||
if (kgets_collected < kgets_want) {
|
||||
kgets_buffer[kgets_collected] = ch;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/**
|
||||
* Serial Port Driver
|
||||
* vim:tabstop=4
|
||||
* vim:noexpandtab
|
||||
*/
|
||||
#include <system.h>
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ start_shell() {
|
|||
fs_node_t * node = fs_root;
|
||||
char * username = "kernel";
|
||||
char * hostname = "toaru";
|
||||
ansi_init();
|
||||
while (1) {
|
||||
/* Read buffer */
|
||||
char buffer[1024];
|
||||
|
|
|
@ -161,13 +161,6 @@ writech(
|
|||
) {
|
||||
unsigned short *where;
|
||||
unsigned att = attrib << 8;
|
||||
if (use_serial) {
|
||||
serial_send(c);
|
||||
}
|
||||
if (bochs_resolution_x) {
|
||||
bochs_write(c);
|
||||
return;
|
||||
}
|
||||
if (c == 0x08) {
|
||||
/* Backspace */
|
||||
if (csr_x != 0) csr_x--;
|
||||
|
|
|
@ -212,14 +212,15 @@ ansi_put(
|
|||
}
|
||||
|
||||
void
|
||||
ansi_init() {
|
||||
ansi_init(void (*writer)(char), int w, int y) {
|
||||
/* Terminal Defaults */
|
||||
state.fg = 7; /* Light grey */
|
||||
state.bg = 0; /* Black */
|
||||
state.flags = 0; /* Nothing fancy*/
|
||||
state.width = 128; /* 1024 / 8 */
|
||||
state.height = 64; /* 768 / 12 */
|
||||
state.width = w; /* 1024 / 8 */
|
||||
state.height = y; /* 768 / 12 */
|
||||
ansi_ready = 1;
|
||||
ansi_writer = writer;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
#include <system.h>
|
||||
#include <fs.h>
|
||||
|
||||
/* Friggin' frick, this should be a config option
|
||||
* because it's 4096 on some instances of Qemu,
|
||||
* ie the one on my laptop, but it's 2048 on
|
||||
* the EWS machines. */
|
||||
#define BOCHS_BUFFER_SIZE 2048
|
||||
#define PREFERRED_X 1024
|
||||
#define PREFERRED_Y 768
|
||||
#define PREFERRED_VY 4096
|
||||
|
@ -17,7 +22,12 @@ uint16_t bochs_resolution_x = 0;
|
|||
uint16_t bochs_resolution_y = 0;
|
||||
uint16_t bochs_resolution_b = 0;
|
||||
|
||||
uint32_t * BOCHS_VID_MEMORY = (uint32_t *)0xE0000000;
|
||||
/*
|
||||
* Address of the linear frame buffer.
|
||||
* This can move, so it's a pointer instead of
|
||||
* #define.
|
||||
*/
|
||||
uint32_t * bochs_vid_memory = (uint32_t *)0xE0000000;
|
||||
|
||||
#define TERM_WIDTH 128
|
||||
#define TERM_HEIGHT 64
|
||||
|
@ -89,13 +99,13 @@ graphics_install_bochs() {
|
|||
/* Go find it */
|
||||
for (uintptr_t x = 0xE0000000; x < 0xE0FF0000; x += 0x1000) {
|
||||
if (((uintptr_t *)x)[0] == 0xA5ADFACE) {
|
||||
BOCHS_VID_MEMORY = (uint32_t *)x;
|
||||
bochs_vid_memory = (uint32_t *)x;
|
||||
goto mem_found;
|
||||
}
|
||||
}
|
||||
for (uintptr_t x = 0xF0000000; x < 0xF0FF0000; x += 0x1000) {
|
||||
if (((uintptr_t *)x)[0] == 0xA5ADFACE) {
|
||||
BOCHS_VID_MEMORY = (uint32_t *)x;
|
||||
bochs_vid_memory = (uint32_t *)x;
|
||||
goto mem_found;
|
||||
}
|
||||
}
|
||||
|
@ -117,13 +127,13 @@ bochs_set_point(
|
|||
uint16_t y,
|
||||
uint32_t color
|
||||
) {
|
||||
BOCHS_VID_MEMORY[((y + current_scroll) * bochs_resolution_x + x)] = color;
|
||||
bochs_vid_memory[((y + current_scroll) * bochs_resolution_x + x)] = color;
|
||||
}
|
||||
|
||||
void
|
||||
bochs_scroll() {
|
||||
uint32_t size = sizeof(uint32_t) * bochs_resolution_x * (bochs_resolution_y - 12);
|
||||
memmove((void *)BOCHS_VID_MEMORY, (void *)((uintptr_t)BOCHS_VID_MEMORY + bochs_resolution_x * 12 * sizeof(uint32_t)), size);
|
||||
memmove((void *)bochs_vid_memory, (void *)((uintptr_t)bochs_vid_memory + bochs_resolution_x * 12 * sizeof(uint32_t)), size);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -257,12 +267,11 @@ void bochs_redraw() {
|
|||
|
||||
void bochs_term_scroll() {
|
||||
/* Oh dear */
|
||||
if (current_scroll + 12 >= 3072) {//3328) {
|
||||
/* I'd really prefer the much-bigger 4096 - 768 */
|
||||
if (current_scroll + 12 >= BOCHS_BUFFER_SIZE - 768) {
|
||||
/* And here's where it gets hacky */
|
||||
// __asm__ __volatile__ ("cli");
|
||||
uint32_t size = sizeof(uint32_t) * bochs_resolution_x * (bochs_resolution_y - 12);
|
||||
memmove((void *)BOCHS_VID_MEMORY, (void *)((uintptr_t)BOCHS_VID_MEMORY + bochs_resolution_x * (current_scroll + 12) * sizeof(uint32_t)), size);
|
||||
// __asm__ __volatile__ ("sti");
|
||||
memmove((void *)bochs_vid_memory, (void *)((uintptr_t)bochs_vid_memory + bochs_resolution_x * (current_scroll + 12) * sizeof(uint32_t)), size);
|
||||
bochs_set_y_offset(0);
|
||||
} else {
|
||||
bochs_set_y_offset(current_scroll + 12);
|
||||
|
@ -283,7 +292,7 @@ void bochs_term_clear() {
|
|||
csr_x = 0;
|
||||
csr_y = 0;
|
||||
memset((void *)term_buffer, 0x00,TERM_WIDTH * TERM_HEIGHT * sizeof(uint8_t) * 4);
|
||||
memset((void *)BOCHS_VID_MEMORY, 0x00, sizeof(uint32_t) * bochs_resolution_x * bochs_resolution_y);
|
||||
memset((void *)bochs_vid_memory, 0x00, sizeof(uint32_t) * bochs_resolution_x * bochs_resolution_y);
|
||||
bochs_set_y_offset(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp)
|
|||
tasking_install(); /* Multi-tasking */
|
||||
enable_fpu();
|
||||
syscalls_install();
|
||||
ansi_init(&writech, 80, 25);
|
||||
|
||||
/* Kernel Version */
|
||||
kprintf("[%s %s]\n", KERNEL_UNAME, KERNEL_VERSION_STRING);
|
||||
|
@ -144,7 +145,7 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp)
|
|||
/*
|
||||
* Aw man...
|
||||
*/
|
||||
fork();
|
||||
//fork();
|
||||
|
||||
if (getpid() == 1) {
|
||||
while (1) {
|
||||
|
|
Loading…
Reference in New Issue