Scroll function isn't working...
Posted: Thu May 25, 2023 4:31 pm
Hello all. I'm currently working on a (very sloppy) kernel right now, and for some reason, my scroll / newline function won't work. The newline works fine, and it doesn't crash or anything, but it just won't scroll. Is there something obvious I'm missing here?
Code: Select all
int cursorX = 0;
int cursorY = 0;
void newl() {
cursorY++;
cursorX = 0;
//// scrolling
if (cursorY == MAX_ROWS) { // <----- scroll function
char *vidmem = xyToVidmem(0, 1);
while (vidmem < MAX_LEN) {
*(vidmem - (MAX_COLS * 2)) = *vidmem;
*(vidmem - (MAX_COLS * 2) + 1) = *(vidmem + 1);
vidmem += 2;
}
}
}
int xyToVidmem(int x, int y) {
char *vidmem = (char *)VIDEO_ADDRESS;
vidmem += x * 2;
vidmem += y * 2 * MAX_COLS;
return vidmem;
}
int printf(char string[]) {
int len = strlen(string);
char *vidmem = xyToVidmem(cursorX, cursorY);
while (*string != 0) {
cursorX++;
if (cursorX == MAX_ROWS) {
newl();
}
*vidmem++ = *string++;
*vidmem++ = 0x07;
}
newl();
return 0;
}