OSDev.org
https://forum.osdev.org/

Scroll function isn't working...
https://forum.osdev.org/viewtopic.php?f=1&t=56852
Page 1 of 1

Author:  Kaius [ Thu May 25, 2023 4:31 pm ]
Post subject:  Scroll function isn't working...

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:
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;
}

Author:  Octocontrabass [ Thu May 25, 2023 5:28 pm ]
Post subject:  Re: Scroll function isn't working...

Kaius wrote:
Code:
    while (vidmem < MAX_LEN) {

How did you define MAX_LEN?

Author:  Kaius [ Thu May 25, 2023 7:33 pm ]
Post subject:  Re: Scroll function isn't working...

Octocontrabass wrote:
Kaius wrote:
Code:
    while (vidmem < MAX_LEN) {

How did you define MAX_LEN?


That is in another file, but it's been manually calculated and is correct.

Author:  Octocontrabass [ Thu May 25, 2023 9:05 pm ]
Post subject:  Re: Scroll function isn't working...

Kaius wrote:
That is in another file, but it's been manually calculated and is correct.

Prove it.

Kaius wrote:
Code:
  cursorY++;

What prevents this value from increasing forever?

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/