53 lines
889 B
Rust
53 lines
889 B
Rust
|
|
const term_width: u16 = 20;
|
|
const term_height: u16 = 12;
|
|
|
|
static term_x: u16 = 0;
|
|
static term_y: u16 = 0;
|
|
|
|
static vcd: *u16 = 0x2000;
|
|
|
|
fn term_putc(ch: u16)
|
|
{
|
|
if (ch == '\n')
|
|
continue 'next_line;
|
|
|
|
if (ch == '\0')
|
|
continue 'next_col;
|
|
if (ch == ' ')
|
|
continue 'next_col;
|
|
|
|
vcd[term_y * term_width + term_x] = ch;
|
|
|
|
'next_col:
|
|
term_x += 1;
|
|
if (term_x < term_width)
|
|
return
|
|
|
|
'next_line:
|
|
term_x = 0;
|
|
|
|
if (term_y + 1 >= term_height) {
|
|
term_scroll();
|
|
} else {
|
|
term_y += 1;
|
|
}
|
|
}
|
|
|
|
fn term_scroll()
|
|
{
|
|
for row: u16 in 0..term_height - 1 {
|
|
for col: u16 in 0..term_width {
|
|
|
|
vcd[row * term_width + col]
|
|
= vcd[(row + 1) * term_width + col];
|
|
}
|
|
}
|
|
for col: u16 in 0..term_width {
|
|
vcd[(term_height - 1) * term_width + col] = ' ';
|
|
}
|
|
}
|
|
|
|
// vim: syntax=rust
|
|
|