Page 1 of 1

Scroll function isn't working...

Posted: Thu May 25, 2023 4:31 pm
by Kaius
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;
}

Re: Scroll function isn't working...

Posted: Thu May 25, 2023 5:28 pm
by Octocontrabass
Kaius wrote:

Code: Select all

    while (vidmem < MAX_LEN) {
How did you define MAX_LEN?

Re: Scroll function isn't working...

Posted: Thu May 25, 2023 7:33 pm
by Kaius
Octocontrabass wrote:
Kaius wrote:

Code: Select all

    while (vidmem < MAX_LEN) {
How did you define MAX_LEN?
That is in another file, but it's been manually calculated and is correct.

Re: Scroll function isn't working...

Posted: Thu May 25, 2023 9:05 pm
by Octocontrabass
Kaius wrote:That is in another file, but it's been manually calculated and is correct.
Prove it.
Kaius wrote:

Code: Select all

  cursorY++;
What prevents this value from increasing forever?