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

How to work with VGA video mod? How to encode pixels?
https://forum.osdev.org/viewtopic.php?f=1&t=33781
Page 1 of 1

Author:  mrjbom [ Mon Jul 22, 2019 7:22 am ]
Post subject:  How to work with VGA video mod? How to encode pixels?

Hey.
Based on this page, you can understand that the standard VGA BIOS memory includes VGA 320 * 200 with 256 colors. I have a question, how to use a particular mod? How to write in bit color?

Author:  Klakap [ Mon Jul 22, 2019 9:42 am ]
Post subject:  Re: How to work with VGA video mod? How to encode pixels?

Little note at first, if you want use graphic mode and you want use BIOS, dont work with VGA, implement VESA, it contain all modes what you need. VGA is good if you want write driver for graphic card, because you can learn a lot about it.

How use particular mode? At first you must make a decision if you want start graphic mode from BIOS, or without BIOS. If you dont want use BIOS, complete code is in http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c .

Here is code for writing pixels:
Code:
void write_vga_pixel(uint32_t line, uint32_t column, uint8_t color) {
    uint8_t *vga_memory = (uint8_t *) 0xA0000;
    uint32_t offset=0;

    offset=( (line*320) + column);

    vga_memory[offset]=color;
}

Author:  mrjbom [ Mon Jul 22, 2019 10:42 am ]
Post subject:  Re: How to work with VGA video mod? How to encode pixels?

Klakap wrote:
Little note at first, if you want use graphic mode and you want use BIOS, dont work with VGA, implement VESA, it contain all modes what you need. VGA is good if you want write driver for graphic card, because you can learn a lot about it.

How use particular mode? At first you must make a decision if you want start graphic mode from BIOS, or without BIOS. If you dont want use BIOS, complete code is in http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c .

Here is code for writing pixels:
Code:
void write_vga_pixel(uint32_t line, uint32_t column, uint8_t color) {
    uint8_t *vga_memory = (uint8_t *) 0xA0000;
    uint32_t offset=0;

    offset=( (line*320) + column);

    vga_memory[offset]=color;
}


How to use it working in BIOS?

Author:  Klakap [ Mon Jul 22, 2019 11:19 am ]
Post subject:  Re: How to work with VGA video mod? How to encode pixels?

You must be in real mode and use assembler:

Code:
  mov ah, 0  ;BIOS VGA mode interrupt
  mov al, 0x13  ;320x200x8 bpp graphic mode
  int 0x10  ;call bios interrupt


And you are in graphic mode.

Author:  mrjbom [ Mon Jul 22, 2019 11:58 am ]
Post subject:  Re: How to work with VGA video mod? How to encode pixels?

Klakap wrote:
You must be in real mode and use assembler


As far as I know, GRUB loads my kernel into protected mode right away. Is that right? How do I then use 320x200x8bpp graphic mode?

Author:  GMorgan [ Tue Jul 23, 2019 12:52 am ]
Post subject:  Re: How to work with VGA video mod? How to encode pixels?

You'd have to drop back to real mode. If you are using GRUB it can initialise the framebuffer for you.

Honestly all of the BIOS stuff is going away. You might be better off using UEFI if you plan to write your kernel in long mode.

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