OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 9:33 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Terminal Skipping Over Line
PostPosted: Sun Jan 26, 2020 5:11 pm 
Offline

Joined: Sun Jan 26, 2020 3:45 pm
Posts: 2
Basically, I have developed to the point where you can print characters to the screen. But I ran into a issue, the text screen has been scrolled down by one. Working in QEMU, but not real hardware. Here is the code I use for printing:
Code:
#include <stdint.h>
#include <stddef.h>
#include "terminal.h"
#include "asm-io.h"
void disable_cursor()
{
   outb(0x3D4, 0x0A);
   outb(0x3D5, 0x20);
}
uint16_t* video_mem;
int row, column;
static const int width = 80;
static const int height = 25;
uint16_t char_entry(unsigned char c, uint8_t color)
{
  return (uint16_t) c | (uint16_t) color << 8;
}
uint8_t char_color(enum color_list fg, enum color_list bg)
{
  return fg | bg << 4;
}
void printc(char c, int color, int x, int y)
{
  video_mem[y * width + x] = char_entry(c, color);
}
void terminal_init(void)
{
  disable_cursor();
  row = 0;
  column = 0;
  video_mem = (uint16_t*)0xB8000;
  for (int y = 0; y < height; y++){
    for (int x = 0; x < width; x++){
      int spot = y * width + x;
      video_mem[spot] = char_entry(' ', char_color(7, 0));
    }
  }
  row = 0;
  column = 0;
  //long string of characters to print, hopefully filling up the screen
  printc('1', char_color(7, 0), column, row++);
  printc('2', char_color(7, 0), column, row++);
  printc('3', char_color(7, 0), column, row++);
  printc('4', char_color(7, 0), column, row++);
  printc('5', char_color(7, 0), column, row++);
  printc('6', char_color(7, 0), column, row++);
  printc('7', char_color(7, 0), column, row++);
  printc('8', char_color(7, 0), column, row++);
  printc('9', char_color(7, 0), column, row++);
  printc('0', char_color(7, 0), column, row++);
  printc('1', char_color(7, 0), column, row++);
  printc('2', char_color(7, 0), column, row++);
  printc('3', char_color(7, 0), column, row++);
  printc('4', char_color(7, 0), column, row++);
  printc('5', char_color(7, 0), column, row++);
  printc('6', char_color(7, 0), column, row++);
  printc('7', char_color(7, 0), column, row++);
  printc('8', char_color(7, 0), column, row++);
  printc('9', char_color(7, 0), column, row++);
  printc('0', char_color(7, 0), column, row++);
  printc('1', char_color(7, 0), column, row++);
  printc('2', char_color(7, 0), column, row++);
  printc('3', char_color(7, 0), column, row++);
  printc('4', char_color(7, 0), column, row++);
  printc('5', char_color(7, 0), column, row++);
}


Is there any obvious flaw I've made?


Top
 Profile  
 
 Post subject: Re: Terminal Skipping Over Line
PostPosted: Mon Jan 27, 2020 11:17 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5143
djalex234 wrote:
But I ran into a issue, the text screen has been scrolled down by one.

I'm not sure I understand what this means. Are you saying there's an empty space at the top of the screen, and the line of text that should be at the bottom of the screen has been cut off? If so, your monitor may not be calibrated correctly. It's very common for LCD monitors to fail automatic calibration when the screen is mostly black.


Top
 Profile  
 
 Post subject: Re: Terminal Skipping Over Line
PostPosted: Mon Jan 27, 2020 1:27 pm 
Offline

Joined: Sun Jan 26, 2020 3:45 pm
Posts: 2
I forgot that this monitor wasn't top quality, the calibration worked. Didn't seem like that was the issue with stuff like Ubuntu working on it perfectly. Thanks for the idea.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 102 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