OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 7:58 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Scroll function isn't working...
PostPosted: Thu May 25, 2023 4:31 pm 
Offline

Joined: Sat Dec 31, 2022 10:59 am
Posts: 6
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;
}


Top
 Profile  
 
 Post subject: Re: Scroll function isn't working...
PostPosted: Thu May 25, 2023 5:28 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
Kaius wrote:
Code:
    while (vidmem < MAX_LEN) {

How did you define MAX_LEN?


Top
 Profile  
 
 Post subject: Re: Scroll function isn't working...
PostPosted: Thu May 25, 2023 7:33 pm 
Offline

Joined: Sat Dec 31, 2022 10:59 am
Posts: 6
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.


Top
 Profile  
 
 Post subject: Re: Scroll function isn't working...
PostPosted: Thu May 25, 2023 9:05 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 155 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group