Scroll function isn't working...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Kaius
Posts: 20
Joined: Sat Dec 31, 2022 10:59 am
Libera.chat IRC: Kaius

Scroll function isn't working...

Post 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;
}
Octocontrabass
Member
Member
Posts: 5443
Joined: Mon Mar 25, 2013 7:01 pm

Re: Scroll function isn't working...

Post by Octocontrabass »

Kaius wrote:

Code: Select all

    while (vidmem < MAX_LEN) {
How did you define MAX_LEN?
Kaius
Posts: 20
Joined: Sat Dec 31, 2022 10:59 am
Libera.chat IRC: Kaius

Re: Scroll function isn't working...

Post 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.
Octocontrabass
Member
Member
Posts: 5443
Joined: Mon Mar 25, 2013 7:01 pm

Re: Scroll function isn't working...

Post 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?
Post Reply