OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 04, 2021 10:19 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: XGA graphics
PostPosted: Sat Jan 23, 2021 11:09 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 33
How would I modify this for XGA screens:
Code:
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <kernel/tty.h>

#include "vga.h"

static const size_t VGA_WIDTH = 80;
static const size_t VGA_HEIGHT = 25;
static uint16_t* const VGA_MEMORY = (uint16_t*) 0xB8000;

static size_t terminal_row;
static size_t terminal_column;
static uint8_t terminal_color;
static uint16_t* terminal_buffer;

void terminal_initialize(void) {
   terminal_row = 0;
   terminal_column = 0;
   terminal_color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
   terminal_buffer = VGA_MEMORY;
   for (size_t y = 0; y < VGA_HEIGHT; y++) {
      for (size_t x = 0; x < VGA_WIDTH; x++) {
         const size_t index = y * VGA_WIDTH + x;
         terminal_buffer[index] = vga_entry(' ', terminal_color);
      }
   }
}

void terminal_setcolor(uint8_t color) {
   terminal_color = color;
}

void terminal_putentryat(unsigned char c, uint8_t color, size_t x, size_t y) {
   const size_t index = y * VGA_WIDTH + x;
   terminal_buffer[index] = vga_entry(c, color);
}

void terminal_putchar(char c) {
   unsigned char uc = c;
   terminal_putentryat(uc, terminal_color, terminal_column, terminal_row);
   if (++terminal_column == VGA_WIDTH) {
      terminal_column = 0;
      if (++terminal_row == VGA_HEIGHT)
         terminal_row = 0;
   }
}

void terminal_write(const char* data, size_t size) {
   for (size_t i = 0; i < size; i++)
      terminal_putchar(data[i]);
}

void terminal_writestring(const char* data) {
   terminal_write(data, strlen(data));
}


:mrgreen:

_________________
Live Long And Prosper


Top
 Profile  
 
 Post subject: Re: XGA graphics
PostPosted: Sat Jan 23, 2021 11:29 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 22, 2019 5:46 am
Posts: 576
Are you sure the following is correct?
Code:
      if (++terminal_row == VGA_HEIGHT)
         terminal_row = 0;

I would expect scrolling instead.

And XGA: I can't find info about XGA text mode on the net. So I guess if a XGA screen has text mode, it will be VGA compatible. Sorry, I don't know.

Greetings
Peter

_________________
The "fanboy" ;)
https://wiki.osdev.org/User:PeterX


Top
 Profile  
 
 Post subject: Re: XGA graphics
PostPosted: Sat Jan 23, 2021 11:30 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 33
I assumed that it was right because I copied off of the wiki page.

_________________
Live Long And Prosper


Top
 Profile  
 
 Post subject: Re: XGA graphics
PostPosted: Sat Jan 23, 2021 11:40 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 22, 2019 5:46 am
Posts: 576
PavelCheckov wrote:
I assumed that it was right because I copied off of the wiki page.

Well, it kind of works. But it will jump to the first line when it reaches the bottom of the screen. That's usually not very reader-friendly. So I would suggest scrolling intead (copying every line one line "higher" and then continue printing at the bottom of the screen.)

EDIT:
I changed https://wiki.osdev.org/Meaty_Skeleton#k ... 86.2Ftty.c
I hope the code I added is not ugly or complicated and has no bugs.

Greetings
Peter

_________________
The "fanboy" ;)
https://wiki.osdev.org/User:PeterX


Top
 Profile  
 
 Post subject: Re: XGA graphics
PostPosted: Sat Jan 23, 2021 10:51 pm 
Offline
Member
Member

Joined: Tue Aug 11, 2020 12:14 pm
Posts: 95
PeterX wrote:
And XGA: I can't find info about XGA text mode on the net. So I guess if a XGA screen has text mode, it will be VGA compatible.

XGA was IBM's attempt at creating a new graphics standard for their PS/2 line way back in the late '80s. It was fully VGA backwards-compatible. Beyond that, I don't know if the specifications were ever publicly released.


Top
 Profile  
 
 Post subject: Re: XGA graphics
PostPosted: Sun Jan 24, 2021 9:57 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1310
PeterX wrote:
Well, it kind of works. But it will jump to the first line when it reaches the bottom of the screen. That's usually not very reader-friendly. So I would suggest scrolling intead (copying every line one line "higher" and then continue printing at the bottom of the screen.)
That's the purpose of the wiki: give a bare minimal working example. It was never a goal to provide fully featured, well-organized source code that anybody can copy'n'paste ;-) Just blindly copying code together without understanding is kinda supposed to fail :-)

PeterX wrote:
EDIT:
I changed https://wiki.osdev.org/Meaty_Skeleton#k ... 86.2Ftty.c
I hope the code I added is not ugly or complicated and has no bugs.
Looks okay to me, thank you very much Peter!

sj95126 wrote:
XGA was IBM's attempt at creating a new graphics standard for their PS/2 line way back in the late '80s. It was fully VGA backwards-compatible. Beyond that, I don't know if the specifications were ever publicly released.
I have a book on it, but it is by no means an official document. According to that book, teletype mode (aka. text mode) is exactly the same as VGA's, there's only difference in graphics mode resolutions and packed pixel formats.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: XGA graphics
PostPosted: Mon Jan 25, 2021 11:41 am 
Offline
Member
Member

Joined: Tue Aug 11, 2020 12:14 pm
Posts: 95
Btw, I was looking through my dumping ground of ancient technical documents and downloads and found that a package released in the 1990s called "VGADOC 4/WHATVGA 2.00" has technical specs on the XGA I/O registers. You can still find this package with a google search.


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

All times are UTC - 6 hours


Who is online

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