Finished Part I, moved part 2 relavent files to own folder.
This commit is contained in:
17
Part2/A4/04_scroll/kernel/kernel.c
Executable file
17
Part2/A4/04_scroll/kernel/kernel.c
Executable file
@@ -0,0 +1,17 @@
|
||||
#include "../drivers/screen.h"
|
||||
#include "util.h"
|
||||
|
||||
void _start() {
|
||||
clear_screen();
|
||||
|
||||
/* Fill up the screen */
|
||||
int i = 0;
|
||||
for (i = 0; i < 24; i++) {
|
||||
char str[255];
|
||||
int_to_ascii(i, str);
|
||||
kprint_at(str, 0, i);
|
||||
}
|
||||
|
||||
kprint_at("This text forces the kernel to scroll. Row 0 will disappear. ", 60, 24);
|
||||
kprint("And with this text, the kernel will scroll again, and row 1 will disappear too!");
|
||||
}
|
23
Part2/A4/04_scroll/kernel/util.c
Executable file
23
Part2/A4/04_scroll/kernel/util.c
Executable file
@@ -0,0 +1,23 @@
|
||||
void memory_copy(char *source, char *dest, int nbytes) {
|
||||
int i;
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
*(dest + i) = *(source + i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* K&R implementation
|
||||
*/
|
||||
void int_to_ascii(int n, char str[]) {
|
||||
int i, sign;
|
||||
if ((sign = n) < 0) n = -n;
|
||||
i = 0;
|
||||
do {
|
||||
str[i++] = n % 10 + '0';
|
||||
} while ((n /= 10) > 0);
|
||||
|
||||
if (sign < 0) str[i++] = '-';
|
||||
str[i] = '\0';
|
||||
|
||||
/* TODO: implement "reverse" */
|
||||
}
|
2
Part2/A4/04_scroll/kernel/util.h
Executable file
2
Part2/A4/04_scroll/kernel/util.h
Executable file
@@ -0,0 +1,2 @@
|
||||
void memory_copy(char *source, char *dest, int nbytes);
|
||||
void int_to_ascii(int n, char str[]);
|
Reference in New Issue
Block a user