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

XGA graphics
https://forum.osdev.org/viewtopic.php?f=13&t=40101
Page 1 of 1

Author:  PavelChekov [ Sat Jan 23, 2021 11:09 am ]
Post subject:  XGA graphics

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:

Author:  PeterX [ Sat Jan 23, 2021 11:29 am ]
Post subject:  Re: XGA graphics

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

Author:  PavelChekov [ Sat Jan 23, 2021 11:30 am ]
Post subject:  Re: XGA graphics

I assumed that it was right because I copied off of the wiki page.

Author:  PeterX [ Sat Jan 23, 2021 11:40 am ]
Post subject:  Re: XGA graphics

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

Author:  sj95126 [ Sat Jan 23, 2021 10:51 pm ]
Post subject:  Re: XGA graphics

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.

Author:  bzt [ Sun Jan 24, 2021 9:57 am ]
Post subject:  Re: XGA graphics

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

Author:  sj95126 [ Mon Jan 25, 2021 11:41 am ]
Post subject:  Re: XGA graphics

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.

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